[PySide] Parent widget not resizing when adding another widget (loaded from a ui file) to a vertical layout

Thomas Robitaille thomas.robitaille at gmail.com
Thu Mar 3 09:55:10 CET 2016


Hi everyone,

I'm having an issue that occurs only with PySide (not PyQt). I am
doing the following:

* Setting up a widget in which I set a vertical layout
* Showing the widget
* Making another widget defined by a .ui file
* Adding this new widget to the vertical layout of the first (this is
deliberately done after the first widget has already been shown)

If I do this, the first widget is not resized, and when I resize it,
the size of the second widget inside does not change.

A minimal example is provided here:

https://gist.github.com/astrofrog/42c43f74b6a09fe54cf2

However, this does work in PyQt4. Is this a bug in PySide? I found
that in my case, a workaround is to do:

        self.ui = loader.load('options_widget.ui', None)
        self.setLayout(self.ui.verticalLayout)

but this is not ideal, so I wanted to check whether anyone can explain
the underlying reason for the behavior?

Thanks!
Tom



More information about the PySide mailing list