我想将QMdiarea
应用于QMainwindow
的{{1}}上,关于QSplitter
的帖子很少,但没有一个真正说明如何应用于此类{{ 1}}。
我的代码:
QMdiarea
我想要实现的是:结果显示
感谢您的帮助。
答案 0 :(得分:3)
您必须创建一个QMdiArea,将其设置为centralWidget,然后使用addSubWindow()方法添加mainSplitter:
class Mywindow(QtWidgets.QMainWindow):
def __init__(self, parent=None):
super(Mywindow, self).__init__(parent)
self.setMinimumSize(QtCore.QSize(1200, 800))
self.setWindowTitle("MdiArea")
self.mdiarea = QtWidgets.QMdiArea()
self.setCentralWidget(self.mdiarea)
self.groupone = QtWidgets.QTextEdit()
self.grouptwo = QtWidgets.QListWidget()
self.groupthree = QtWidgets.QTextEdit()
self.groupfour = QtWidgets.QListWidget()
self.V_Splitter = QtWidgets.QSplitter(QtCore.Qt.Vertical)
self.V_Splitter.addWidget(self.groupone)
self.V_Splitter.addWidget(self.grouptwo)
self.viewSplitter = QtWidgets.QSplitter(QtCore.Qt.Vertical)
self.viewSplitter.addWidget(self.groupthree)
self.viewSplitter.addWidget(self.groupfour)
self.mainSplitter = QtWidgets.QSplitter(QtCore.Qt.Horizontal)
self.mainSplitter.addWidget(self.V_Splitter)
self.mainSplitter.addWidget(self.viewSplitter)
self.mainSplitter.setStretchFactor(0, 1)
self.mainSplitter.setStretchFactor(1, 5)
self.viewSplitter.setStretchFactor(0, 1)
self.viewSplitter.setStretchFactor(1, 1)
self.mdiarea.addSubWindow(self.mainSplitter)
# ...