[PyQt] Fwd: Mixin classes and PyQt4

Phil Thompson phil at riverbankcomputing.com
Mon Feb 10 22:42:27 GMT 2014


On 10-02-2014 7:47 pm, Baz Walter wrote:
> 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.

So what if you had a second mixin that handled, say, 
QObject.connectNotify() in the same way?

Phil


More information about the PyQt mailing list