Layouts are actually easy to understand "I think" :)
A simple explanation of the layouts can be found in the qt book " C ++ Programming with QT 2nd edition
What you need to know about layouts and their size policies
- Most Qt widgets have a size policy. This size policy tells the system how the widget should stretch or contract. It got out of the QSizePolicy class. Size policy has both vertical and horizontal components.
- Most widgets also have a size hint. This size hint tells the system about preferred widget sizes
- QSizePolicy has a stretch factor that allows widgets to grow at different speeds.
I know only 4 size policies
- fixed size policy. The widget size is fixed and cannot be stretched. It stays behind the size hint.
- minimum size policy - size hint - this is the minimum possible size of the widget, but it can increase if necessary.
- Preferred size policy - the widget can shrink or grow larger than the size hint.
- size expansion policy - the widget may decrease or increase more than its tip :)
You can ask,
What is the difference between preferred and expanding?
Answer: Imagine a form with two widgets, one with a preferred one and the other with an extension. Then additional space is added for the expanding widget. The preferred policy widget will remain with a size hint.
I recommend (WARNING: not an expert :)) you buy and read “ C ++ programming using QT 2nd edition . I currently read it and make a lot of sense. Look at the images and see if they make sense.
Size Policies Explained

Simple example
This is a simple two-button dialog for which horizontal and vertical dimension policies are shown, as well as horizontal and vertical stretching.

Here is the smallest preview. 
Here is another preview at a larger size 
[EDITED: // size hint example added]
WHY YOU SHOULD BE PROVIDED FOR ACCOMMODATION
You can see that each widget has sizeHint, which is vital because the QT layout system always respects sizeHint. This is only a problem if the default widget size is not quite what you want. The only way to solve this problem is to extend (subclass) the widget and reimplement its sizeHint () member function. An example is 1000 words. To save space, see my blog for an example project.
Dr Deo Jan 12 '11 at 18:29 2011-01-12 18:29
source share