smerlin
smerlin

Reputation: 6566

shrink the parent window instead of having other widgets grow

I have a window, which only contains one groupbox, which contains several more groupboxes in a QVBoxLayout (the content of those doesnt have a fixed size either). Those inner groupboxes are checkable, and unchecking them collapses them (collapsed groupbox has a reduced (maximum)height of 30px and isFlat==true).

What i am trying to achieve is: When one of the inner groupboxes is collapsed, the outer groupbox and the window should shrink accordingly (currently the other non-collapsed groupboxes grow instead). But the user should still be able to resize the window, which should cause the groupboxes to grow accordingly:

alt text I was toying around with QWidget::setSizePolicy and QLayout::setSizeConstraint of the different layouts/widgets, but havent come to a satisfying result yet..
Whats the best way to achieve this ? Can this be done without implementing your own size-hint functions ?

Upvotes: 1

Views: 1020

Answers (1)

dabhaid
dabhaid

Reputation: 3879

I made a toy case that seems to have the behaviour you require by calling

adjustSize();

on the parent QGroupBox after resizing the inner QGroupBoxes. I made this a slot so I could connect it to the same signal that resizes the inner group box for convenience.

Upvotes: 2

Related Questions