Results 1 to 4 of 4

Thread: Resizing all the QWidgets while resizing the main window

  1. #1
    Join Date
    Feb 2010
    Posts
    10
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60

    Default Resizing all the QWidgets while resizing the main window

    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!
    Last edited by AL; 2nd March 2010 at 16:26.

  2. #2
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    4,380
    Thanks
    19
    Thanked 1,005 Times in 913 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60
    Wiki edits
    5

    Default Re: Resizing all the QWidgets while resizing the main window

    Use layouts (QLayout, QGridLayout, QHBoxLayout...), choose the right policies and let Qt do the job.

  3. #3
    Join Date
    Feb 2010
    Posts
    10
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60

    Default Re: Resizing all the QWidgets while resizing the main window

    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

  4. #4
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    4,380
    Thanks
    19
    Thanked 1,005 Times in 913 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60
    Wiki edits
    5

    Default Re: Resizing all the QWidgets while resizing the main window

    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.

Similar Threads

  1. Resizing a maximized, custom-frame window
    By Claymore in forum Qt Programming
    Replies: 9
    Last Post: 24th November 2010, 19:17
  2. Resizing window depending on QTableView
    By Ferric in forum Newbie
    Replies: 2
    Last Post: 9th February 2010, 05:17
  3. resizing widgets depending on a main widget size
    By luf in forum Qt Programming
    Replies: 6
    Last Post: 10th October 2009, 17:13
  4. Replies: 11
    Last Post: 11th August 2008, 10:14
  5. [QT4] Any way to disable window resizing ?
    By Amalsek in forum Qt Programming
    Replies: 5
    Last Post: 15th May 2006, 12:36

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.