質問

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.

役に立ちましたか?

解決

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

vbox.addStretch()
ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top