[PyQt] Fwd: Mixin classes and PyQt4

Baz Walter bazwal at ftml.net
Mon Feb 10 19:47:59 GMT 2014


On 10/02/14 18:43, Phil Thompson wrote:
> On 10-02-2014 6:16 pm, Baz Walter wrote:
>>
>> Why not simply:
>>
>> class A(object):
>>     def sizeHint(self):
>>         print('mixed in!', self.parent())
>>         return super().sizeHint()
>>
>> class B(A, QLabel):
>>     pass
>>
>> class C(A, QLabel):
>>     pass
>
> That was my first reaction, but having to do...
>
> class B(A, QLabel)
>
> ...rather than...
>
> class B(QLabel, A)
>
> ...isn't nice.
>

What would be the point of the second one?

The mixin would always need to go first for subclasses to benefit from 
the reimplemented sizeHint.

-- 
Regards
Baz Walter


More information about the PyQt mailing list