Details
-
Suggestion
-
Resolution: Unresolved
-
P5: Not important
-
None
-
5.3.0 Beta1
-
None
Description
Adding the second layout to QWidget causes this message:
QLayout: Attempting to add QLayout "" to QGroupBox "", which already has a layout
In principle, widgets should allow multiple layouts. Some child widgets can be managed by one layout, and some other child widgets — by some other layout. There is nothing wrong with such disposition. Child widgets (siblings) may overlap in such case, but this is up to the user to set their Z order and design such layout properly. This is certainly not for a mainstream dialog design, but can add a lot of flexibility to some particular cases.
layout() will return the first (or only) layout, and layouts() will return the list of layouts.
Particular application which led to this suggestion:
I tried to add some extra "floating" widget in the corner of otherwise "normal" QVBoxLayout managed dialog. QBoxLayout with Qt::AlignRight|Qt::AlignTop would have achieved this, but an additional layout can't be added.
Currently, it is possible to solve this problem using QStackedLayout and setting transparent background of one of the widgets, but this is more convoluted.