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

QObject is not usable in __init__() of classes after the QObject in MRO

    XMLWordPrintable

Details

    • Bug
    • Resolution: Unresolved
    • Not Evaluated
    • None
    • 6.5.0, 6.6.0
    • PySide, Shiboken
    • None
    • All

    Description

      Consider the following code (see attachment for full working code):

      class A:
          def __init__(self):
              super().__init__()
      
      class B(QObject, A):
          def __init__(self, parent=None):
              super().__init__(parent)
      

      Any class after the QObject in the MRO can not make use of the QObject inside their __init__(): None of the QObject’s methods work, self can not be used as parent for another QObject and str(self)/repr(self) fail.

      Looking at the bindings code generated by Shiboken, this is because Shiboken::callInheritedInit() – which implements super() – is called before before the underlying C++ QObject is created. SIP does the opposite. That is, in PyQt one can use the QObject in __init__() of classes which follow the QObject in the MRO.

      Attachments

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

        Activity

          People

            ctismer Christian Tismer
            rear1019 A R
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:

              Gerrit Reviews

                There are no open Gerrit changes