How to properly layout this form



  • In the first image the layout is good. But this the size in Qt Designer. The second image is this window maximized. You can see that the text in the upper portion has gained height. The widget on the bottom left is a label that will hold a pixmap. The two stacked widgets on the right are QChartViews. What I want is, when the window is maximized, the image label and the charts to increase in size and the text at the top to stay the same. I've tried grouping them together in sections and grid layouts. Nothing I do makes it do what I want it to do. Could I get some advice?

    ![alt text](0_1557326169047_1.PNG image url)
    0_1557326180655_2.PNG



  • Hi @PsylumDan,

    You need to put stretch factor to 1 for your bottom part, so it will grow instead of your text.

    With QBoxLayout, you can do that using the second argument of QBoxLayout::addWidget or QBoxLayout::addLayout
    With QGridLayout, you can set stretch by row using QGridLayout::setRowStretch



  • Thanks for the quick reply. I'm doing this in the Qt Designer. Should I be doing it with code instead?



  • @PsylumDan Hum Ok,

    No, you can do it by clicking on the root widget containing your layout. Then go at bottom of the properties editor, you can see a section Layout, here you can change the layoutStretch property of each widget.
    Example with 2 widgets, by default you have 0,0, you can put 0,1 to set the last widget having the "growing priority".

    Sorry it could be simple with a picture. But I cannot post them because of proxy.


  • Lifetime Qt Champion

    @PsylumDan
    Hi
    You can also do it in Designer.
    alt text

    here told it that to top one should use 2/3 and last should use 1/3
    of the space.



  • Thanks guys. With ya'lls help I got it working as expected.


Log in to reply
 

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