How to use QApplication in Qt
Jump to navigation
Jump to search
Introduction[edit | edit source]
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[edit | edit source]
- include <QApplication>
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
//
// code
return app.exec();
}
See also[edit | edit source]
- QApplication (Qt Reference)