I have always used a QApplication object in the main function, as is used generally. What I am a bit curious about is this: when and why should one subclass QApplication?
Thanks
Nupul
I have always used a QApplication object in the main function, as is used generally. What I am a bit curious about is this: when and why should one subclass QApplication?
Thanks
Nupul
You must subclass QApplication when you want to change the behavior of one or more of its virtual methods.
Here's an example: http://www.qtcentre.org/forum/showth...0399#post10399
Or if you want to embed the whole application data into one object (for example to avoid global variables). You can then override QCoreApplication::instance() to return your "extended" pointer. And your main() can look like this then:
Qt Code:
#include "myapplication.h" int main(int argc, char **argv){ MyApplication app(argc, argv); return app.exec(); }To copy to clipboard, switch view to plain text mode
nupul (20th April 2006)
Bookmarks