[PyQt] Fwd: Mixin classes and PyQt4
Phil Thompson
phil at riverbankcomputing.com
Sun Feb 16 22:29:11 GMT 2014
On 16-02-2014 8:42 pm, Baz Walter wrote:
> 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)
For the "correctness" of the QMetaObject. sigC should appear in
MyLabel's QMetaObject but not Z's. However if that correctness is not
important then it's a bit easier.
Phil
More information about the PyQt
mailing list