Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

Resizing Layout equal to MainWindow



  • When I run my program it will display all content properly, and when I resizing the main window, the layout along with all associated widgets remain fixed, rather than resizing with the main window. I used to increase my all widget and listWidget respect to window computer resolution size but still this one work properly.
    I used this one code finding the system height and width.
    QWidget widget;
    widget.resize(widget.width(), widget.minimumHeight());
    QRect rec = QApplication::desktop()->screenGeometry();
    int h = rec.height();
    int w = rec.width();
    // Increasing the listwidget size
    ui->listWidget->setFixedHeight(h);
    ui->listWidget->setFixedWidth(w);
    //increasing the button size
    ui->pushButton->setFixedHeight(h0.2);
    ui->pushButton->setFixedWidth(w
    0.2);

    Please resolve to solve my problem. Thanks very much in advance.


  • Qt Champions 2017

    Looks like you are using the designer to write the UI. I suspect that you have not added the layout properly. Can you confirm whether base class is QMainWindow or Widget ? Are you applying the layout properly in Designer to top widget ?


Log in to reply