The variable qApp is a global pointer that refers to the single object
application. It is equivalent to the pointer returned by the function
QCoreApplication::instance()
, except that, in GUI applications, it is a
pointer to an instance of QApplication
.
http://doc.qt.io/qt-4.8/qapplication.html#qApp
Being qApp
an instance of QCoreApplication
, one of the differences is that the method quit
is a SLOT
, that is, it can be used in response to a Qt signal.
Signals & Slots
Another difference between the methods is that the quit
always returns 0 (zero), while the method exit
can receive an integer number to return a different code.
void Qcoreapplication::quit()
void Qcoreapplication::Exit(int returnCode = 0)
That is, both methods should be used when the application should be closed, but the quit
, which does not allow error code assignment, can be used directly in connection with a signal, and the exit
, which allows error code assignment, can only be used in the conventional way.