I currently have a horziontal layout that has two vertical layouts in it. Vlayout1
and VLayout2
. Now I want to set a maximum width limit of VLayout1
so that if the form is expanded after that, only Vlayout1
expands.
Any suggestions on how I could accomplish this?
QVBoxLayout::QVBoxLayout(QWidget *parent)Constructs a new top-level vertical box with parent parent. The layout is set directly as the top-level layout for parent. There can be only one top-level layout for a widget. It is returned by QWidget::layout().
To place unused space left or right of the text edit put the QTextEdit into a QHBoxLayout and use one of the functions addSpacerItem() , addSpacing() or addStretch() to add spacing.
The Qt layout system provides a simple and powerful way of automatically arranging child widgets within a widget to ensure that they make good use of the available space.
You can do a "hack" and place your layout inside a widget, for which you can define a maximum width:
QWidget *controlsRestrictorWidget = new QWidget();
QVBoxLayout *layoutVControls = new QVBoxLayout();
controlsRestrictorWidget->setLayout(layoutVControls);
controlsRestrictorWidget->setMaximumWidth(350);
It works :)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With