[PyKDE] Multiple inheritance.

Phil Thompson phil at river-bank.demon.co.uk
Tue Dec 7 13:55:53 GMT 1999


Toby Sargeant wrote:
> 
> I don't know whether this will be considered a bug worth fixing (or indeed
> whether it'll be fixable; it's certainly a nasty problem), but I thought I'd
> share it anyway:
> 
> import qt
> class A(qt.QObject,qt.QPixmap):
>    def __init__(self):
>       qt.QObject.__init__(self)
>       qt.QPixmap.__init__(self,100,100)
> 
> class B(qt.QObject,qt.QPixmap):
>    def __init__(self):
>       qt.QPixmap.__init__(self,100,100)
>       qt.QObject.__init__(self)
> 
> import sys
> q=qt.QApplication(sys.argv)
> a=A()
> print a.width()
> b=B()
> print b.width()
> 
> 100
> Traceback (innermost last):
>   File "test_multi.py", line 18, in ?
>     print b.width()
> SystemError: NULL result without error in call_object
> 
> Toby.

I don't think it's fixable.  The calls to the QObject and QPixmap ctors
are both creating C++ instances - and the first one created is being
forgotten.

If you really needed to do this you would have to create A and B as C++
classes in a separate library - and then use SIP to generate bindings
for that library.

Phil





More information about the PyQt mailing list