Unsolved pyside6-designer custom widget already deleted issue
-
Running: Python 3.11.1, PySide6==6.4.2 on Windows 11.
Given the following custom widget;
class MyWidget(PySide6.QtWidgets.QCheckBox): def _update_screen(self, screen): pass def showEvent(self, event): window = self.window().windowHandle() window.screenChanged.connect(self._update_screen)
This widget runs fine when used in an application.
However when this widget is deployed as a custom widget in pyside6-designer and dragged onto a UI, pyside6-designer runs into an exception which is shown when pyside6-designer is stopped;
Error: Traceback (most recent call last): File "C:\Temp\designer_issue\widget.py", line 12, in showEvent window.screenChanged.connect(self._update_screen) RuntimeError: Internal C++ object (PySide6.QtGui.QWindow) already deleted. while executing 'C:\Temp\designer_issue\.venv\Lib\site-packages\PySide6\designer'
The self.window() is;
<PySide6.QtWidgets.QMainWindow(0x1f873cc70a0, name="MDIWindow") at 0x000001F8748946C0>
and the apparently deleted self.window().windowHandle() is;
<PySide6.QtGui.QWindow(0x1f873f47020, name="MDIWindowWindow") at 0x000001F874894740>
Do I need to check if the Internal C++ object is deleted and how do I do this?
As to the origin of the Widget code, see;
matplotlib.backends.backend_qt.FigureCanvasQT