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

Eric Jardim ericjardim at gmail.com
Thu Sep 8 23:52:09 BST 2005


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. But you don't 
need to have both on the same object. You can have a "child" object of your 
MyThread class, and you can act like a proxy to it.

BTW, in Qt4, QThread is also a QObject.

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()'), ('',))

Bye,

[Eric Jardim]
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.riverbankcomputing.com/pipermail/pyqt/attachments/20050909/e0028700/attachment.html


More information about the PyQt mailing list