
Originally Posted by
wysota
In general the top level widget asks its layout to position its items according to the top level widget size. Then the layout asks each of its items for their sizeHint. Then the real size is calculated based on the size hint, minimum and maximum sizes and size policies. Then widgets are repositioned and asked to adjust their layouts.
For me it sounds that once top level widget set size of their layout items - their sizes won't change. If children placed in layout requires more space to be drawn correctly - there's no way to change size 'auto-magically'.
Once problem is only ONE LEVEL deep - it's ok.
Look below.
-------------DIALOG-----------------------------------
| -------------groupBox1--------------------------- |
| | item_1 | |
| | item_2 | |
| | - item_2_1 | |
| | item_3 | |
| | item_4 | |
| ------------------------------------------------- |
| -------------groupBox2--------------------------- |
| | item_1 | |
| | item_2 | |
| | ... | |
| ------------------------------------------------- |
| -------------groupBox3--------------------------- |
| | item_1 | |
| ------------------------------------------------- |
-----------------------------------------------------
-------------DIALOG-----------------------------------
| -------------groupBox1--------------------------- |
| | item_1 | |
| | item_2 | |
| | - item_2_1 | |
| | item_3 | |
| | item_4 | |
| ------------------------------------------------- |
| -------------groupBox2--------------------------- |
| | item_1 | |
| | item_2 | |
| | ... | |
| ------------------------------------------------- |
| -------------groupBox3--------------------------- |
| | item_1 | |
| ------------------------------------------------- |
-----------------------------------------------------
To copy to clipboard, switch view to plain text mode
Dialog Layout prepares space for all groupBoxes. If they are without sizeHint, minimum- , maximumSize and sizePolicies - size of all would be the same.
Now - as long no item_x_1 is showed - no problem. It looks ok.
When item_2_1 is show() - space for groupBox1 is not enough. groupBox1 inside layout tries to place all items as best as possible in given space. But its not enough.
Perfectly would be if - when item_2_1->show() layout gets info - I need more space. Then he send this info to layout()->parent(), which reorganizes his layout to give more space to this child.
In other place I used something like that - when user clicked inside groupBox - widget which was hidden is now showed. While processing click signal - I'm increasing this groupBox vertical stretch.
It works, but - in my opinion - result aren't ... elegant.
Modifying sizeHint, maximumSize and minimumSize when new child member is showed - with Layouts use - is nonsense and pointless.
Here I should transfer signal to Dialog, change stretchFactor and redraw - not nice and flexible enough.
Sounds -
Bookmarks