How to use QApplication in Qt
Article Metadata
Compatibility
Platform(s): Qt
Article
Keywords: QApplication
Created: kamaljaiswal
(16 Jan 2008)
Last edited: hamishwillee
(11 Oct 2012)
Introduction
The QApplication class manages the GUI application's control flow and main settings.
For all Qt GUI application, there is one QApplication object, whether the application has one or more windows at any time. For non-GUI Qt applications, QCoreApplication is used instead of QApplication, which doesn't depend on the QtGui library.
It initializes the window system and constructs an application object with argc command line arguments in argv. The global qApp pointer refers to this application object. Only one application object should be created.
This application object must be constructed before any paint devices (including widgets, pixmaps, bitmaps etc.).
Code Snippet
#include <QApplication>
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
//
// code
return app.exec();
}
See also
- QApplication (Qt Reference)


This article is one of the very basic article of Qt it is well-explained in Overview of article how to use QApplication class.
This article is well but if you want to know more about this class than you can go on below link http://doc.trolltech.com/4.5/qapplication.html
This article is very useful for beginners it will not useful for intermediate.
--nayan_trivedi 14:23, 17 September 2009 (UTC)
There is nothing insight the article but it has a grand thing to use QApplication. Article shows the use of QApplication header file very clearly. Adding the capital function with argument in this article may clear about this approach.
[--fasttrack 17:51, 22 September 2009 (UTC)]