Search code examples
qtqlayout

Re sizing a Qt application without using a layout manager


I am trying to make it so a GUI I built in Qt will re size to any users window. I know this is traditionally done using a layout manager, however none of the layout managers suit my needs. Every manager seems to create disproportional widgets. Is there any way to just make of my widgets and certain percent of the screen. I want to maintain the current relative positioning of my widgets and just have them re size as the screen re sizes by the same factor.


Solution

  • Is there any way to just make of my widgets and certain percent of the screen.

    verticalLayout->addWidget(new QTextEdit);
    verticalLayout->addWidget(new QTextEdit);
    verticalLayout->setStretch(0, 1);   // 33%
    verticalLayout->setStretch(1, 2);   // 66%
    

    Also, setting minimumSize and maximumSize helps alot.