[PyQt] Fwd: Mixin classes and PyQt4

Baz Walter bazwal at ftml.net
Sun Feb 16 20:42:17 GMT 2014


On 16/02/14 13:27, Phil Thompson wrote:
> On 12-02-2014 9:55 pm, Baz Walter wrote:
>> I understand that Qt itself doesn't allow this, but is there a
>> technical reason why this is not possible in PyQt? There is a real,
>> practical need for this functionality (code reuse), and its galling
>> that PySide allows it but PyQt doesn't.
>
> It's technically possible, just a bit of a hack. Consider...
>
> class A(object):
>      sigA = pyqtSignal()
>
> class B(A):
>      pass
>
> class C(object):
>      sigC = pyqtSignal()
>
> class MyLabel(C, QLabel):
>      pass
>
> class Z(B, MyLabel):
>      pass
>
> It needs to work out that the QMetaObject for Z must include sigA but
> not sigC.

I'm probably misunderstanding you, but:

Why should Z not include sigC? What should happen if an instance of Z 
attempted to emit sigC in this example?

(PS: I tried this example in PySide, and both signals can be 
successfully emitted by instances of Z)

-- 
Regards
Baz Walter


More information about the PyQt mailing list