Resize Objects With Mainwindow Resize

  • hi,
    i dropped 3 button and a label in my window
    but i want when i resize my window,
    my objects resize with it too,
    how i can do this?

  • Lifetime Qt Champion


    Use layouts. Look in the documentation for QHBoxLayout, QVBoxLayout and friends. For designer, there's the Using Layouts in Qt Designer chapter of Qt's documentation.

  • hi,

    but in documentation dose Not explained this and just referred Layouts
    i have a code that do this(resize),
    but i want to question that it is possible to do this in visual design?
    tnx a lot

  • Lifetime Qt Champion

    If you use layouts and put the buttons in one. Then no need
    for any code to do resize.

    So using layouts is how you do in Visual Design.

    Try this :
    Make new project
    open the mainwindow UI
    Place a button in the empty mainwindow.
    Right click empty spot on form
    Select the Layout menu (bottom)
    Select Layout Horizontally

Log in to reply

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.