My layout understanding needs improvement

RoadrunnerWMC roadrunnerwmc at gmail.com
Thu Apr 22 19:41:26 BST 2021


You *can* nest layouts in Qt, but you do it by adding the inner layout to
the outer layout:

group1 = qtw.QVBoxLayout()
self.setLayout(group1)
button_row = qtw.QHBoxLayout()
group1.addLayout(button_row)

This would behave a little differently from a QGridLayout because the
widgets in each row aren't forced to line up into columns if they have
different widths.

On Thu, Apr 22, 2021 at 1:41 PM Rich Shepard <rshepard at appl-ecosys.com>
wrote:

> On Thu, 22 Apr 2021, Vincent Vande Vyvre wrote:
>
> > There's two layouts on the main widget:
> >
> >         group1 = qtw.QVBoxLayout()
> >         self.setLayout(group1)                      # 1
> >
> >         button_row = qtw.QHBoxLayout()
> >         self.setLayout(button_row)               # 2 ! Remove this line.
>
> Vincent,
>
> Okay. I was thinking in wxPython terms where I could nest layouts; e.g., a
> set of horizontal (row) layouts within a vertical layout.
>
> I'll use a QGridLayout instead.
>
> Thanks very much,
>
> Rich
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://www.riverbankcomputing.com/pipermail/pyqt/attachments/20210422/822538bb/attachment.htm>


More information about the PyQt mailing list