[PyQt] multiple inheritance suggestion
Phil Thompson
phil at riverbankcomputing.com
Sat Apr 14 14:12:59 BST 2012
On Sun, 8 Apr 2012 22:40:04 -0400, Luke Campagnola
<lcampagn at email.unc.edu>
wrote:
> Howdy list,
>
> I'm trying to achieve some sort of multiple inheritance with custom
classes
> where each may define its own signals. I understand there are
limitations
> with SIP in this area, but It is not really necessary that QObject be
> inherited more than once. As an example, consider the standard diamond
> inheritance problem:
>
> A
> / \
> B C
> \ /
> D
>
> If A is a subclass of QObject, then presumably classes B, C, and D could
> all define their own signals (creating an instance of class D should
only
> result in a single C++ QObject instance, so in theory this should work
> fine).
No, because Qt doesn't support it as it only handles "linear" chains of
meta-objects.
> In practice, this causes a segmentation fault when emitting signals
> that were defined in class C.
I've fixed it to raise an exception instead.
> I'm not sure if this is a solvable problem at
> all, but suggestions are welcome. I could potentially sidestep the issue
by
> breaking the inheritance between A and C, but then I can no longer
define
> signals from class C (Or rather, I can define signals, but attempting to
> emit such a signal also leads to segmentation fault).
>
> Any ideas? Is there perhaps a way (using new-style signals) to send a
> signal that is not defined as a class attribute?
>
> Thanks,
> Luke
Phil
More information about the PyQt
mailing list