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

QMainWindow and multiple inheritance from QWidget

    XMLWordPrintable

Details

    • Bug
    • Resolution: Out of scope
    • Not Evaluated
    • None
    • 6.5.2
    • PySide
    • None
    • macOS

    Description

      What was working in 6.4.x does not seem to be possible in 6.5.x. Running following code snippet:

      import sys
      
      from PySide6.QtCore import QLibraryInfo, qVersion
      from PySide6.QtWidgets import QApplication, QWidget, QMainWindow
      
      
      class MyWidget(QWidget):
          pass
      
      
      class Window(QMainWindow, MyWidget):
          def __init__(self):
              super().__init__()
      
      
      if __name__ == '__main__':
          print('Python {}.{}'.format(sys.version_info[0], sys.version_info[1]))
          print(QLibraryInfo.build())
          app = QApplication(sys.argv)
          window = Window()
          window.setWindowTitle(qVersion())
          window.show()
          sys.exit(app.exec_())
      

      throws an exception and outputs the following:

      Python 3.10
      Qt 6.5.0 (x86_64-little_endian-lp64 shared (dynamic) release build; by Apple LLVM 14.0.0 (clang-1400.0.29.202)) [limited API]
      Traceback (most recent call last):
        File "/Users/christianr/Documents/workspace/sett/sett/gui/Window.py", line 20, in <module>
          window = Window()
        File "/Users/christianr/Documents/workspace/sett/sett/gui/Window.py", line 13, in __init__
          super().__init__()
      RuntimeError: You can't initialize an PySide6.QtWidgets.QMainWindow object in class Window twice!
      

      How can I fix this? Thanks in advance.

      Attachments

        1. pyside2282.py
          1 kB
          Friedemann Kleint

        Issue Links

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

          Activity

            People

              crmaurei Cristian Maureira-Fredes
              ribose Christian Ribeaud
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Gerrit Reviews

                  There are no open Gerrit changes