How to use QApplication in Qt
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.).
int main(int argc, char *argv)
QApplication app(argc, argv);
- QApplication (Qt Reference)