Nominate our 2022 Qt Champions!

auto resize widget when mainwindow is resized

  • Hi all. Using Qt designer, I drew my mainwindow and in a new file, my custom widget.. It's name is "Form" (of corse Form extend QWidget class). In my mainwindow i have a QWidget pattern, it's name is "widgetadd".. and in my mainwindow i have created by code my custom widget using:
    Form * f = new Form(ui->widgetadd);


    My FORM has a GridLayout and if i try to resize it in designer, all label and QLineEdit resizing.
    The problem is when i run my project, when i resize mainwindow my widget doesnt't resize!
    Could someone help me?

    Result when i run my project:

  • Lifetime Qt Champion

    Did you insert the widget into the layout ?
    You should add the (form) widget to widgetadd's layout.
    something like
    if (widgetadd->layout())

Log in to reply