Layout - adjust size to its content
-
How can I force my layout to adjust its size as per the child widgets. What I have is a vertical layout on my QMainWidget. I am adding sub widgets to it based on some conditions. I need my vertical layout to shrink and expand based on the number of widgets I add to my vertical layout.
-
There is showcase for the same. See http://developer.qt.nokia.com/forums/viewthread/2766/
-
I am not sure if that is what I need.. I saw the video, there the size of the layout is same and child widgets are adjusted to available space.
What I am looking for is if my layout has two widget with 100 px by 100 px , by layout should adjust to size 100px by 200 px, and if I have three widget my layout should adjust to size 100px by 300 px
-
Use QDesktopWidget::screenGeometry to get the screen size and then you can decide based on the ratio you want for your widgets. You can then use QLayout::SetFixedSize in case you want the layout to be of exactly fixed size.