一、QCoreApplication用于non-GUI的应用程序(不需要依赖QtGui库),QApplication用于包含GUI的应用程序(需要用到QtGui库)。
二、QApplication继承了QGuiApplication类,而QGuiApplication继承了QCoreApplication类,而QCoreApplication又继承QObject的,而QObject就是QT中最基本的基类,也就是QT的根基。
QCoreApplication和QApplication用法说明:
QCoreApplication
The QCoreApplication class provides an event loop for console Qt applications.
This class is used by non-GUI applications to provide their event loop. For non-GUI application that uses Qt, there should be exactly one QCoreApplication object. For GUI applications, see QApplication.
QCoreApplication contains the main event loop, where all events from the operating system (e.g., timer and network events) and other sources are processed and dispatched. It also handles the application's initialization and finalization, as well as system-wide and application-wide settings.
QApplication
The QApplication class manages the GUI application's control flow and main settings.
QApplication contains the main event loop, where all events from the window system and other sources are processed and dispatched. It also handles the application's initialization, finalization, and provides session management. In addition, QApplication handles most of the system-wide and application-wide settings.
For any GUI application using Qt, there is precisely one QApplication object, no matter whether the application has 0, 1, 2 or more windows at any given time. For non-GUI Qt applications, use QCoreApplication instead, as it does not depend on the QtGui library.
The QApplication object is accessible through the instance() function that returns a pointer equivalent to the global qApp pointer.