[PyQt] multiple inheritance and signals problem, mixin before QObject

lloyd konneker bootch at nc.rr.com
Thu Sep 12 15:30:06 BST 2013

This is an update to my previous post.
Here is an abstract of the code for easier reading:

class B(object):
   def __init__(self):
     self.a1 = A()
     self.a1.signal1.connect(self.handler)    # Fails in PyQt, succeeds 
in PySide

   def handler(self):

class A (Mixin, SubclassOfQObject):
   def __init__(self):

class Mixin(object):
   signal1 = Signal()
   def __init__(self):

Again, AFAIK this works in PySide, but not in PyQt.
The MRO of a1, an instance of class A, is (Mixin, SubclassOfQObject, 
QObject, object).
And Mixin.__init__ calls super, which calls QObject.__init__ for 
instance a1,
so the signal instance should be bound by the time its connect method is 

I found that a workaround is to eliminate the mixin:

class A (SubclassOfQObject):
   signal1 = Signal()
   def __init__(self):

   ... methods that were in Mixin ...

I just don't understand why.  Should I submit an executable test case?

More information about the PyQt mailing list