Resize Window



  • Hi,

    how can I resize a widget with a QVBoxLayout containing different widgets keeping the proportions of each widget within the layout?



  • Ok, I think the widgets inside the QVBoxLayout will change as you change the size of the Widget containing the QVBoxLayout.

    So my advice will be to set the size of the Widgets inside your QVBoxLayout to the same value everytime you change the size of the Widget containing the QVBoxLayout.

    But you might check the "QVBoxLayout ":http://qt-project.org/doc/qt-5.0/qtwidgets/qvboxlayout.html reference because there might be some property that could help you to acomplish this.



  • you can use setFixedSize(QSize) if you want the widget to stay a specific size or setMinimumSize.



  • Hello,
    If you want to keep the relative dimensions of the widgets in you layouts (i.e the height of widget A. is two times the height of widget B and C and four times the height of widget D), you should use the strech factor which is the second argument of @QVBoxLayout::addWidget(QWidget* w, int strech)@

    Example :
    @
    layout->addWiget(widgetA, 4);
    layout->addWiget(widgetB, 2);
    layout->addWiget(widgetC, 2);
    layout->addWiget(widgetD, 1);
    @

    If you want to keep the aspect ration (i.e. the ratio height/width), I don't know any good solution (since this would involve adapting the width of the dialog).
    
    Hope it helps. Regards,

Log in to reply
 

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