Details
-
Bug
-
Resolution: Unresolved
-
P3: Somewhat important
-
None
-
6.5.1.1
-
None
Description
Consider the following code:
import sys from PySide6.QtCore import QObject from PySide6.QtWidgets import QApplication, QWidget class AnotherObject(QObject): pass class MyWidget(QWidget, AnotherObject): def __init__(self, parent: QWidget | None = None) -> None: super().__init__(parent) # RuntimeError: You can't initialize an PySide6.QtWidgets.QWidget object in class Window twice! app: QApplication = QApplication(sys.argv) MyWidget()
Where commented, the mentioned error occurs. Instead of QWidget, theĀ MyWidget class may inherit any subclass of QObject but QObject itself, i.e., QComboBox, QLabel, QFrame, etc. Moreover, the issue reproduces with any two subclasses of the same Qt class, provided the first one is a Qt class, and the another is Pythonic, e.g., QLabel and any derivative of QWidget.
The error does not show up on PyQt5, PySide2, or PyQt6.
Attachments
Issue Links
- duplicates
-
PYSIDE-2282 QMainWindow and multiple inheritance from QWidget
- Closed
- relates to
-
PYSIDE-1564 QObject does not support cooperative multiple inheritance
- Closed