PDA

View Full Version : Resizing all the QWidgets while resizing the main window



AL
2nd March 2010, 15:20
Hello,
I have a main window with lots of widgets on it (moreover Qlabels with images, buttons, checkboxes, ...). I would like to resize all of them (proportionally) automatically while the main window is resized.

For example: I have a mainwindow with a QLabel (with a png image in it) and this label width and height take the 50% of the main window, I would like that, when I resize the main window to any size, the QLabel width and height will be always the 50% of the main window (and obviously the image has to stretch)

How can I do that?

Tx!

Lykurg
2nd March 2010, 15:29
Use layouts (QLayout, QGridLayout, QHBoxLayout...), choose the right policies and let Qt do the job.

AL
2nd March 2010, 16:24
tx Lykurg I would be happy to let Qt do the job :)

I tried on a new empty project but I do not understand how to use the layouts :S
I have created a new Qt prj (File->New->Qt4 Gui App) and added on the mainwindow some QWidgets (a label and a Text browser). Then I selected them and clicked on the "Layout in a form layout". And then? What is the right field to change?

Tx a lot

Lykurg
2nd March 2010, 20:58
Form layout is only one of the possibilities Qt offers you. Just go to the manual and read about layouts. It is very well explained in the docs. There are also many examples which uses layouts. Read them too to understand layouts. More I can hardly say.