[PyKDE] Is it possible to fake multiple inheritance with PyQt ?

İsmail Dönmez ismail at uludag.org.tr
Fri Sep 9 00:00:28 BST 2005


Cuma 09 Eylül 2005 01:52 tarihinde, Eric Jardim şunları yazmıştı: 
> 2005/9/8, İsmail Dönmez <ismail at uludag.org.tr>:
> > Hi all,
> > I need to emit some signals from a class inheriting from QThread so I
> > need to
> > inherit from QObject too but PyQt has no support for multiple inheritance
> > so
> > I tried following code to fake it :
>
> You are not "faking" MI, with this. You are actualy doing it.
Yeah but its not working as say it does in C++

> BTW, in Qt4, QThread is also a QObject.
Yeah I noticed too, which is a good thing.

>
> but it doesn't work as expected and gives attribute error on line 21 :
> > self.emit(PYSIGNAL('success()'), ('',)) part. So its not really
> > inheriting from QObject. I wonder if anyone knows if we can fake multiple
> > inheritance like this or is it impossible ?
>
> Try putting QObject before QThread:
>
> class Thread(QObject, QThread):
> def __init__(self):
> QObject.__init__(self)
> QThread.__init__(self)
> self.emit(PYSIGNAL('success()'), ('',))

Then I can't use QThread functions like start() which shows this is still not 
100% inheritance.

Regards,
ismail




More information about the PyQt mailing list