PYQT布局和setgeometry基本概述
PYQT layout and setgeometry basic overview
我试图让我的 qsplitlines 在我的程序启动时设置为基本形状。我一直在研究 setgerometry(x, x, x, x) 中的 4 个数字,我能简单解释一下它们之间的关联吗?
从上开始,?,从左边开始,?
(从上往下,从左往下,连续,横跨多少行)
hbox = QtGui.QHBoxLayout(self)
topleft = QtGui.QFrame(self)
topleft.setFrameShape(QtGui.QFrame.StyledPanel)
topleft.setGeometry(0, 0, 300, 0)
topright = QtGui.QFrame(self)
topright.setFrameShape(QtGui.QFrame.StyledPanel)
topright.setGeometry(0, 320, 1000, 0)
bottom = QtGui.QFrame(self)
bottom.setFrameShape(QtGui.QFrame.StyledPanel)
bottom.setGeometry(1210, 0, 1280, 0)
splitter1 = QtGui.QSplitter(QtCore.Qt.Horizontal)
splitter1.addWidget(topleft)
splitter1.addWidget(topright)
splitter2 = QtGui.QSplitter(QtCore.Qt.Vertical)
splitter2.addWidget(splitter1)
splitter2.addWidget(bottom)
hbox.addWidget(splitter2)
self.setLayout(hbox)
#QtGui.QApplication.setStyle(QtGui.QStyleFactory.create('Cleanlooks'))
我将在底部的答案之前向您展示如何浏览文档。它将在长期 运行.
中为您提供帮助
从 QFrame
文档开始。您正在寻找 setGeometry
方法。您会注意到没有一个,但是 QFrame 确实继承自 QWidget
转到 QWidget
documentation you'll find that there is are two setGeometry
方法
QWidget.setGeometry (self, QRect)
和
QWidget.setGeometry (self, int ax, int ay, int aw, int ah)
第一个接受 QRect
,第二个接受一系列整数。让我们也看看 QRect
文档:
A QRect can be constructed with a set of left, top, width and height integers
这与其他方法采用的整数系列一致。来自 Qt Documentation 的这张图片有助于解释它:
因此,您的整数是:
- X坐标
- Y坐标
- 框架的宽度
- 框架的高度
我试图让我的 qsplitlines 在我的程序启动时设置为基本形状。我一直在研究 setgerometry(x, x, x, x) 中的 4 个数字,我能简单解释一下它们之间的关联吗?
从上开始,?,从左边开始,?
(从上往下,从左往下,连续,横跨多少行)
hbox = QtGui.QHBoxLayout(self)
topleft = QtGui.QFrame(self)
topleft.setFrameShape(QtGui.QFrame.StyledPanel)
topleft.setGeometry(0, 0, 300, 0)
topright = QtGui.QFrame(self)
topright.setFrameShape(QtGui.QFrame.StyledPanel)
topright.setGeometry(0, 320, 1000, 0)
bottom = QtGui.QFrame(self)
bottom.setFrameShape(QtGui.QFrame.StyledPanel)
bottom.setGeometry(1210, 0, 1280, 0)
splitter1 = QtGui.QSplitter(QtCore.Qt.Horizontal)
splitter1.addWidget(topleft)
splitter1.addWidget(topright)
splitter2 = QtGui.QSplitter(QtCore.Qt.Vertical)
splitter2.addWidget(splitter1)
splitter2.addWidget(bottom)
hbox.addWidget(splitter2)
self.setLayout(hbox)
#QtGui.QApplication.setStyle(QtGui.QStyleFactory.create('Cleanlooks'))
我将在底部的答案之前向您展示如何浏览文档。它将在长期 运行.
中为您提供帮助从 QFrame
文档开始。您正在寻找 setGeometry
方法。您会注意到没有一个,但是 QFrame 确实继承自 QWidget
转到 QWidget
documentation you'll find that there is are two setGeometry
方法
QWidget.setGeometry (self, QRect)
和
QWidget.setGeometry (self, int ax, int ay, int aw, int ah)
第一个接受 QRect
,第二个接受一系列整数。让我们也看看 QRect
文档:
A QRect can be constructed with a set of left, top, width and height integers
这与其他方法采用的整数系列一致。来自 Qt Documentation 的这张图片有助于解释它:
因此,您的整数是:
- X坐标
- Y坐标
- 框架的宽度
- 框架的高度