[PyQt] qApp and QApplication are not the same
phil at riverbankcomputing.co.uk
Thu Oct 11 10:26:49 BST 2007
On Thursday 11 October 2007, Nahuel Defossé wrote:
> I've created my QApplication class like this:
> class MyApp(QtGui.QApplication):
> def __init__(self, *args):
> super(MyApp, self).__init__(*args)
> # bla bla bla
> mywin = MyWin()
> def say_hello(self):
> print "Hello"
> But, within MyWin if I call QtGui.qApp.say_hello, it says it's not
> defined... It's even worse, if I ask for QtCore.qApp's type it says
> There's no cast in python, is it? How could I get extra methods I defined
> in my custom QApp class?
The easiest way is to add...
QtGui.qApp = self
Personally I always use QApplication.instance() instead of qApp.
More information about the PyQt