Description
When a QWidget that has been inserted in a QTabWidget gets its parent() (or parentWidget()) method called, non-owning Python objects [that are wrapping Qt objects that are present in the widget's hierarchy] are wrongly invalidated.
The issue manifests when the widget is inserted in a QTabWidget, but not with other organizer widgets such as QSplitter. The intermediate QStackedWidget in QTabWidget may be contributing to the issue.
In the following snippet, assume that a "menu" object exists in a menu bar inside the widget (self) which lives in a tab in a QTabWidget:
menu = self.findChild(QtCore.QObject, 'menu') print(Shiboken.isValid(menu)) # Prints "True" self.parent() # Wrongly invalidates `menu` print(Shiboken.isValid(menu)) # Prints "False"
An example Qt application (test_app.py) has been attached to easily reproduce the unexpected behavior.
Attachments
For Gerrit Dashboard: PYSIDE-2711 | ||||||
---|---|---|---|---|---|---|
# | Subject | Branch | Project | Status | CR | V |
559118,3 | Fix undesired invalidation of QObjects/QWidgets after calling parent(Widget)() | dev | pyside/pyside-setup | Status: MERGED | +2 | 0 |