2

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:

desired result

However, when increasing the size of the DockWidget, the GroupBoxes drift apart:

current result

...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.

ekhumoro
  • 115,249
  • 20
  • 229
  • 336
Henry
  • 141
  • 9

1 Answers1

2

Try adding an expanding spacer to the end of the vbox:

vbox.addStretch()
ekhumoro
  • 115,249
  • 20
  • 229
  • 336