Try adding an expanding spacer to the end of the vbox:
vbox.addStretch()
Frage
I have a QDockWidget containing several QGroupBoxes. (The content of the QGroupBoxes is shown/hidden upon mousePressEvent.) I'm looking for a way to keep the QGroupBoxes positioned as tightly together as possible, preferably at the top of the DockWidget. It should look something like this:
However, when increasing the size of the DockWidget, the GroupBoxes drift apart:
...which is very convenient in most cases, I know. But is there a way to override this behavior and get a nice, expandable, list-like grouping of Widgets?
The DockWidget contains a QGroupBox; the QGroupBoxes 'Foo', 'Bar' and 'Baz' are added to that box's QVBoxLayout.
Lösung
Try adding an expanding spacer to the end of the vbox:
vbox.addStretch()