Uploaded image for project: 'Qt for Python'
  1. Qt for Python
  2. PYSIDE-2397

RuntimeError when instantiating a class, which inherits multiple subclasses of a Qt class, some Pythonic, some Qt ones

    XMLWordPrintable

Details

    • Bug
    • Resolution: Unresolved
    • P3: Somewhat important
    • None
    • 6.5.1.1
    • Shiboken
    • 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

          No reviews matched the request. Check your Options in the drop-down menu of this sections header.

          Activity

            People

              ctismer Christian Tismer
              stsav012 Anton Yablokov
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

                Created:
                Updated:

                Gerrit Reviews

                  There are no open Gerrit changes