开发者

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 us开发者_开发知识库er should still be able to resize the window, which should cause the groupboxes to grow accordingly:

shrink the parent window instead of having other widgets grow

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 ?


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜