Im trying to get my qsplitlines to set to a basic shape upon startup of my program. I have been playing around with the 4 numbers in setgerometry(x, x, x, x) Could I get a simple explanation of what they correlate too?
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'))
In PyQt, layout managers are classes that provide the required functionality to automatically manage the size, position, and resizing behavior of the widgets in the layout. With layout managers, you can automatically arrange child widgets within any parent, or container, widget.
setGeometry() method is used to set up the geometry of the PyQt5 window it self. Syntax : window.setGeometry(x, y, width, height)
Getting to Know PyQt. PyQt is a Python binding for Qt, which is a set of C++ libraries and development tools providing platform-independent abstractions for graphical user interfaces (GUIs).
The QWidget class is the base class of all user interface objects.
I'm going to show you how to walk through the documentation before the answer at the bottom. It'll help you in the long run.
Start with the QFrame
documentation. You are looking for a setGeometry
method. You'll notice that there isn't one, but the QFrame does inherit from the QWidget
Going to the QWidget
documentation you'll find that there is are two setGeometry
methods
QWidget.setGeometry (self, QRect)
and
QWidget.setGeometry (self, int ax, int ay, int aw, int ah)
The first one takes a QRect
and the second takes series of integers. Let's look at the QRect
docs too:
A QRect can be constructed with a set of left, top, width and height integers
This lines up with the series of integers the other method takes. This image from the Qt Documentation helps explain it:
Thus, your integers are:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With