[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>
> Howdy list,
> I'm trying to achieve some sort of multiple inheritance with custom
> where each may define its own signals. I understand there are
> 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
> 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

> 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
> breaking the inheritance between A and C, but then I can no longer
> 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


More information about the PyQt mailing list