<br><br><div class="gmail_quote">On Sat, Apr 14, 2012 at 09:12, Phil Thompson <span dir="ltr"><<a href="mailto:phil@riverbankcomputing.com">phil@riverbankcomputing.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
On Sun, 8 Apr 2012 22:40:04 -0400, Luke Campagnola<br>
<<a href="mailto:lcampagn@email.unc.edu">lcampagn@email.unc.edu</a>><br>
wrote:<br>
<div class="im">>As an example, consider the standard diamond<br>
> inheritance problem:<br>
><br>
> A<br>
> / \<br>
> B C<br>
> \ /<br>
> D<br>
><br>
> If A is a subclass of QObject, then presumably classes B, C, and D could<br>
> all define their own signals (creating an instance of class D should<br>
only<br>
> result in a single C++ QObject instance, so in theory this should work<br>
> fine).<br>
<br>
</div>No, because Qt doesn't support it as it only handles "linear" chains of<br>
meta-objects.<br>
<div class="im"><br></div></blockquote><div><br></div><div>Thanks, Phil, I didn't realize this was a limitation of Qt. </div><div><br></div><div>I did find an easy workaround, though: instead of defining class C as a QObject subclass, I just give it a separate QObject attribute as a proxy for sending and receiving signals. Looks like this:</div>
<div><br></div></div><blockquote style="margin:0 0 0 40px;border:none;padding:0px"><div class="gmail_quote"><div>class C:</div><div> class QObjectProxy(QObject):</div><div> sig = QtCore.pyqtSignal()</div><div><br>
</div><div> def __init__(self):</div><div> self.proxy = QObjectProxy()</div><div> self.sig = self.proxy.sig</div><div><br></div></div></blockquote>Then for instances of class C, I can call c.sig.emit() or c.sig.connect(...) in the usual way and this works well with multiple inheritance.<div>
<br></div><div>Luke<br><blockquote style="margin:0 0 0 40px;border:none;padding:0px"><div class="gmail_quote"><div><br></div><div><br></div></div></blockquote></div>