Child Layouts not getting added Properly
-
Guys , here my MainWindow is not a QMainWindow,instead ,it inherits from QWidget.Moreover I dont use the .ui form and I create the UI dynamically.
-
Sorry @J-Hilk ,but Im not using it .I tried to add both setMinimumHeight and setMaximumHeight and it works now.Could you tell me when these two functions should be used?
@Adit What about http://doc.qt.io/qt-5/qwidget.html#setLayout ?
You created a layout (parentLayout), but you did not tell your MainWindow widget to use it. -
I guess stretch factors can be 0 or 1 (contract and expand) right?What if we have multiple Layouts of specific sizes ?
@Adit said in Child Layouts not getting added Properly:
I guess stretch factors can be 0 or 1 (contract and expand) right?What if we have multiple Layouts of specific sizes ?
no, 0 means, take as much space, as possible, defined by the sizepolicy and sizehint of the Widget/Layout
in this case a stretch factor of 1 for each element results in the following space for the layouts, 1/3, 1/3 and 1/3.
With for example
parentLayout->setStretch(0,1); parentLayout->setStretch(1,1); parentLayout->setStretch(2,2);
the layouts take up 1/4, 1/4, 1/2 of the available space.
-
If we are using this setStretch() method, then can we use setMaximumWidth() and setMaximumHeight() methods?