<div dir="ltr"><div>As we all know, PyQt doesn't allow multiple inheritance of more Qt classes, except when explicitly allowed (eg. QTextObjectInterface).</div><div><br></div><div>When using the Graphics View framework, though, it is sometimes useful to have a QGraphicsItem subclass that also provides QObject features: for example, a QGraphicsRectItem that emits a signal whenever its geometry changes.</div><div><br></div><div>Right now, whenever I need something similar, I normally choose one of the following options, depending on my needs and code simplicity:</div><div><br></div><div>- create a dummy QObject subclass and use an instance of it as a member of the actual QGraphicsItem one, then eventually emit its signals whenever necessary;</div><div>- create a dummy QGraphicsObject subclass as the actual one to be used, with the "real" items as its children, then implementing <span style="font-family:monospace">boundingRect()</span> (possibly returning <span style="font-family:monospace">childrenBoundingRect()</span>) and a no-op <span style="font-family:monospace">paint()</span>, and eventually "copying" the actual child item common functions by proper implementation, simple monkey patching or even __getattr__ override;</div><div><br></div><div>While both solutions "work", they are not really acceptable, nor robust or reliable:</div><div><br></div><div>- the dummy QObject "proxy" is an unnecessary difficulty that complicates access to the actual signal source; using Qt properties is a further complication (consider the case of using QPropertyAnimation);<br></div><div>- the "main QGraphicsObject" approach adds complexity and further difficulties in geometry/transform management and access to the actually intended item;</div><div>- issues with the lifespan of the QObject and the "real" QGraphicsItem, including connected signals (eg. using QTimers or animations);<br></div><div><br></div><div>Qt actually considers and allows such multiple inheritance (it's the very nature of QGraphicsObject).</div><div><br></div><div>So, my question is quite simple: would it be possible to allow proper multiple inheritance for QGraphicsItem+QObject?</div><div>Therefore, would that implicitly allow multiple inheritance for all QGraphicsItem inherited classes (the standard ones and those created in Python, including mixins)?<br></div><div><br></div><div>Thanks,</div><div>MaurizioB<br></div><div><br><span class="gmail_signature_prefix">-- </span><br><div dir="ltr" class="gmail_signature" data-smartmail="gmail_signature">È difficile avere una convinzione precisa quando si parla delle ragioni del cuore. - "Sostiene Pereira", Antonio Tabucchi<br><a href="http://www.jidesk.net" target="_blank">http://www.jidesk.net</a></div></div></div>