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

lloyd konneker bootch at nc.rr.com
Thu Sep 12 00:32:38 BST 2013


I am trying to switch from PySide to PyQt.

The following code seemed to work in PySide:

class FramedViewedTextGlyph(CompositeGlyph, ViewSizeable, Proxiable, 
QGraphicsItemGroup): # no class inherits QObject
   def __init__(self):
     super(FramedViewedTextGlyph, self).__init__() # init group necessary?

     # Children
     self.viewedText = self._initChildGlyph(childGlyph=ViewedTextGlyph())
     ....
     # new style signals, could not get this to work in PyQt
self.viewedText.viewSizeChanged.connect(self._resizeFrameAndProxy)# line 52

class ViewedTextGlyph(TextView, QGraphicsTextItem): # ! QGTI inherits 
QObject
   def __init__(self):
     super(ViewedTextGlyph, self).__init__()

class TextView(object):
   # Mixin
   viewSizeChanged = Signal(QSizeF)
   def __init__(self):
     super(TextView, self).__init__()
   ...
   def emitSizeChange(self):
     self.viewSizeChanged.emit(self.viewSize)    # line 315

With PyQt I get:

Program error:  Program error: <b>TypeError'>: connect() failed between 
[QSizeF] and unislot()</b> on line 52, file framedViewedTextGlyph.py
Object::connect: Use the SIGNAL macro to bind ViewedTextGlyph::(QSizeF)

So I changed the connect to the old style:

QtCore.QObject.connect(self.viewedText, 
QtCore.SIGNAL('viewSizeChanged(QSizeF)'), self._resizeFrameAndProxy)

Now I get:

Program error:  Program error: <b>AttributeError'>: signal was not 
defined in the first super-class of class 'ViewedTextGlyph'</b> on line 
315, file textview.py

But it appears to me that the signal IS defined in the first 
super-class, which is TextView.

I see some examples where the mixin follows the Qt class in the MRO.  I 
tried that, with appropriate?? changes to the init calls).  I also tried 
the original ordering, but with TextView inheriting QObject instead of 
object (and appropriate?? explicit init calls.)  No luck.

I don't want you to debug my code, but any hints?  At worst, I will 
simplify the mixin inheritance, or do away with the signals altogether.


More information about the PyQt mailing list