문제

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