[PyQt] multiple inheritance and signals problem, mixin before QObject
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
super(FramedViewedTextGlyph, self).__init__() # init group necessary?
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
viewSizeChanged = Signal(QSizeF)
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:
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