PyQt5实现split分隔栏

from  PyQt5 import  QtCore,QtGui
from  PyQt5.QtGui import *
from  PyQt5.QtCore import *
import sys
# QtCore.QTextCodec.setCodecForTr(QtCore.QTextCodec.codecForName("utf8"))
class Csplitter(QtGui.QMainWindow):
 def __init__(self,parent=None):
     super(Csplitter,self).__init__(parent)
     self.resize(400,400)
     self.setWindowTitle('Pyqt Qsplitter')
     self.textedit = QTextEdit()
     self.textedit.setText("This is a TextEdit!")
     self.listwidget = QListWidget()
     self.listwidget.addItem("This is  a \nListWidget!")
     self.listwidget.addItem("aaaaaaaaaaaaaaa")
     self.treewidget = QTreeWidget()
     self.treewidget.setHeaderLabels(['This','is','a','TreeWidgets!'])
     splitter = QSplitter(self)
     splitter.addWidget(self.textedit)
     splitter.addWidget(self.listwidget)
     splitter.addWidget(self.treewidget)
     splitter.setOrientation(Qt.Vertical)    # Qt.Vertical 垂直   Qt.Horizontal 水平
     self.setCentralWidget(splitter)

if __name__ == '__main__':
 app= QtGui.QApplication(sys.argv)
 main = Csplitter()
 main.show()
 sys.exit(app.exec_())

你可能感兴趣的:(PyQt5,Python)