[PyQt] Two base classed inherit QWidget

simozack simozack at yahoo.it
Mon Feb 2 10:43:13 GMT 2009


2009/1/31, Filip Gruszczyński <gruszczy at gmail.com>:

> Could someone explain to me, how is that possible and why it works:
>
> class A(QWidget):
>  def __init__(self):
>    QWidget.__init__(self)
>
> class B(QWidget):
>  def __init__(self):
>    QWidget.__init__(self)
>
> class C(A, B):
>  def __init__(self):
>    A.__init__(self)
>    B.__init__(self)
>
> I mean, it's cool, that it works - I just used and I love it. But
> having just C(QWidget, QWidget) won't work. Why above example does?

I think it works because A and B are two different and separated
instances of the same object (QWidget) while QWidget is the same
class.

Try to substitute QWidget with the python standard 'object' class and
you have the same behaviour and this error:

'duplicate base class object'

HTH,
Simone



More information about the PyQt mailing list