PDA

View Full Version : Can Layouts Stretch to Fit?



kylemhall
15th December 2009, 13:11
Hey all,
I'm attempting to rewrite a kiosk management program that I originally wrote in GTK. The main problem I'm having is that I cannot make my layouts stretch to fit all available space, so when my application switches to fullscreen mode, nothing is centered. In GTK, the default behavior is stretch to fit, but I cannot find a way to do this in Qt4. What am I missing?

Thanks,
Kyle

wysota
15th December 2009, 16:54
You have to set appropriate size policies for your widgets. It is also possible that you are using layouts incorrectly. Can you give us some more info? An ui file would be nice.

JD2000
17th December 2009, 15:37
Layouts caused me a lot of confusion when I first came across them using the designer.

If you use this to build your UIs you will see a layouts section where you can drag and drop a layout onto your UI.

Do not use this, it will make the UI form the container of your layout just like any other item dragged and dropped on to it, which is probably not what you want and is unlikely to behave as you expect. By default there is nothing to resize the container, so the layout will never get resized.

Instead right click on the item whose layout is to be managed, choose layout from the menu and attach the required layout this way. You can control-click to choose multiple items.

If you are using a container, eg a Tab Widget, you will need to place its contents into layouts first (vertical and horizontal seem to work best) and then allocate the container itself to a another layout.

I hope this makes sense. Good luck.