<div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr">Il giorno lun 3 mag 2021 alle ore 17:22 Rich Shepard <<a href="mailto:rshepard@appl-ecosys.com">rshepard@appl-ecosys.com</a>> ha scritto:<br></div><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">QGroupBox is a container holding layouts with widgets. I want to group six<br>
widgets -- in two rows -- into a groupbox. Having each row of widgets<br>
in a group with the same title was successful, but I'm failing at having<br>
both rows of widgets in a single group box.<br></blockquote><div><br></div><div>I believe you're a bit confused about widgets and layouts.</div><div><br></div><div>Widgets are UI elements that *can* have layout managers set on them.</div><div>Layout managers are items that *manage* the geometry of the children widgets, they ensure that those widgets are properly resized and positioned, and that the widget in which the layout is set has a proper size in order to show all of its contents.</div><div>Qt layouts are based on QLayoutItem, which is an abstract object that represents an item in a layout, and that item can be a widget, another layout (nested layouts) or a spacer.</div><div><br></div><div>You can set a layout by using widget.setLayout(layout) or by adding the widget as an argument in the constructor: layout = QVBoxLayout(widget).</div><div>But, if you want to add a layout *to another one* (nesting), you need to use addLayout(), and you cannot use the argument in the constructor as explained before.</div><div></div></div><div><br></div><div>Also, using tb1.layout() is pointless, as it will return tb1 anyway.</div><div><br></div><div>To summarize:</div><div>- set a layout manager on a widget: widget.setLayout(layout) (or the above constructor);</div><div>- add a widget to a layout: layout.addWidget(widget) (see the docs about the various classes, as there are differences in behavior and some more functions are provided);</div><div>- add a *layout* to a layout: layout.addLayout(otherLayout);</div><div>- get the layout currently set on a widget: widget.layout();</div><div>- do *not* try to use layout.addItem, which is intended for more advanced purposes;</div><div><br></div><div>So, in your case:</div><div>- change all tb1.layout().addWidget(...) to tb1.addWidget(...);</div><div>- you can access the layout set on a widget by using widget.layout(), but since you're creating it in the same scope, there's no need for that: just create it with a reference and use that afterwards: tboxLayout = qtw.QVBoxLayout(tbox);</div><div>- add the child layout correctly: tboxLayout..addLayout(tb1);</div><div>- set the *main* layout for your widget, otherwise you'll certainly face some issues:</div><div><div>        mainLayout = qtw.QVBoxLayout(self)</div><div>        mainLayout.addWidget(tbox)</div></div><div><br></div><div>Read more on <a href="https://doc.qt.io/qt-5/layout.html">https://doc.qt.io/qt-5/layout.html</a> and <a href="https://doc.qt.io/qt-5/designer-layouts.html">https://doc.qt.io/qt-5/designer-layouts.html</a></div><div><br></div><div>As Tomas suggested, you can do some experiments by creating UI in designer and analyze the output of pyuic to understand how they work. Be aware, those files should **NEVER** be modified for production. You can study them, edit them to see the results and understand their behavior, but then keep in mind that they should always be left as they are if you decide to use them in your program. Read more about it on the official docs: <a href="https://www.riverbankcomputing.com/static/Docs/PyQt5/designer.html">https://www.riverbankcomputing.com/static/Docs/PyQt5/designer.html</a></div><div><br></div><div>Maurizio</div>-- <br><div dir="ltr" class="gmail_signature">È difficile avere una convinzione precisa quando si parla delle ragioni del cuore. - "Sostiene Pereira", Antonio Tabucchi<br><a href="http://www.jidesk.net" target="_blank">http://www.jidesk.net</a></div></div></div></div></div></div></div></div></div></div>