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

Mustafa Sakalsiz mustafa at liqia.com
Thu Sep 8 22:22:07 BST 2005


Hi,

You don't always need to make subclasses of QObject to emit signals.

You may use another QObject instance to emit signals.
An example: http://www.opendocs.org/pyqt/index.lxp?lxpwrap=x1807%2ehtm

or you can use QSignal, Qt Assistant have a sample.

Saki

İsmail Dönmez wrote:
> 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
> 
> _______________________________________________
> PyKDE mailing list    PyKDE at mats.imk.fraunhofer.de
> http://mats.imk.fraunhofer.de/mailman/listinfo/pykde




More information about the PyQt mailing list