Anekdotin
Anekdotin

Reputation: 1591

PYQT layout and setgeometry basic overview

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?

From top, ?, From left, ?

(down starting from top, from left, continuing, how many rows it spas across)

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'))

Upvotes: 11

Views: 35721

Answers (1)

Andy
Andy

Reputation: 50540

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:

Window Geometry

Thus, your integers are:

  • X coordinate
  • Y coordinate
  • Width of the frame
  • Height of the frame

Upvotes: 34

Related Questions