PDA

View Full Version : Keeping the left side of a splitter from resizing



MrGarbage
13th December 2007, 19:28
Hi,

In the attached example .ui I have used the Designer to
create a left and right groupbox layed out horizontally in a splitter.

I would like the leftmost groupbox to NOT resize when I horizontally
increase the size of the main window. Using the splitter I can and should
be able to increase or decrease the size of the leftmost groupbox. But it
should remain at it's current width when resizing the main window. Only the
rightmost groupbox should resize.

I cannot find the correct layout settings to accomplish this.

Thank you.

jacek
13th December 2007, 19:50
Set the hSizeType to Expanding and horizontalStretch to 1 for that group box.

MrGarbage
13th December 2007, 22:56
Awesome - that does it thank you.

I must say I don't exactly understand why that works.

I thought that the stretch factors were for establishing ratios between layout
objects, ie this object should get twice as much space as this one.. hence a
stretch factor of 2 and 1.

Any idea where in the QT documentation I would have been able to
derive this info?

Thanks

Mark

jacek
14th December 2007, 19:50
I thought that the stretch factors were for establishing ratios between layout
objects, ie this object should get twice as much space as this one.. hence a
stretch factor of 2 and 1.
Yes, but that's when you have two or more objects with "expanding" policy.

If all widgets have "preferred" policy, then the layout asks each of them how much space it needs and tries to scale them evenly to make them occupy the whole available space. But if there's at least one expanding widget, then all widgets with "preferred" policy will occupy the minimal amount of space they need and the rest of the available space will be divided between expanding widgets according to their stretch factors (and minimal required size).

Although setting the "expanding" policy isn't enough, because you also have to set the stretch factor to a non-zero value. Zero stretch factor means that the widget doesn't want its share.


Any idea where in the QT documentation I would have been able to derive this info?
I don't remember seeing single comprehensive document about layouts and size policies in Qt docs. You might try QSizePolicy, Layout Classes (http://doc.trolltech.com/4.3/layout.html) and Pixel-Perfect Mac + Plastique (http://doc.trolltech.com/qq/qq23-layouts.html).