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

İsmail Dönmez ismail at uludag.org.tr
Thu Sep 8 21:27:46 BST 2005


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 :

===============================
from qt import *

class MyQObject(QObject):
    def __init__(self):
        QObject.__init__(self)

class MyQThread(QThread):
    def __init__(self):
        QThread.__init__(self)

class Thread(MyQThread, MyQObject):
    def __init__(self):
        MyQThread.__init__(self)
        MyQObject.__init__(self)
        self.emit(PYSIGNAL('success()'), ('',))

def test():
    foo = Thread()

if __name__ == "__main__":
    test()
===============================

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 ?

Regards,
ismail




More information about the PyQt mailing list