[PyKDE] qApp is a QApplication instance

Phil Thompson phil at riverbankcomputing.co.uk
Wed Feb 16 16:04:17 GMT 2005


> Hello,
>
>>>> from qt import *
>>>> import sys
>>>> class A(QApplication):
> ...     pass
> ...
>>>> a = A(sys.argv)
>>>> qApp
> <__main__.qt.QApplication object at 0x007FECC0>
>>>> a
> <__main__.A object at 0x008035A0>
>
>
> Is this expected / wanted? I had expected to be able to access the Python
> instance of the application through the global qApp, not the QApplication.
> In Qt, I can down-cast the qApp pointer to my subclass to access my
> methods,
> how can I do the same in PyQt?

sys.modules['qt'].__dict__['qApp'] = A(sys.argv)

...might do it. You have to make sure that this is done before the other
modules that want to use it get imported.

Phil




More information about the PyQt mailing list