[PyQt] Two base classed inherit QWidget

Matt Smith melkor at orangepalantir.org
Mon Feb 2 13:49:17 GMT 2009


> > 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

Have you tried this on a windows system?  I had a program that worked
fine in linux and then when I moved it to windows it failed to exit the
program because I was initializing an object twice.

mbs



More information about the PyQt mailing list