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);

    MAIN WINDOW
    FORM

    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:
    PROJECT RUNNING


  • Qt Champions 2016

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


Log in to reply
 

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