Your main application and its menus
In order to use Qt Widgets, you need to do two things. First, you need to ensure that you include the widgets module in your project by adding the following line in your project's .pro
file:
QT += widgets
Second, any file using the Qt Widgets should include the QWidgets
header as one of the headers. You might also need to include the header files for individual widgets, such as QButton
, QMenuBar
, and so forth:
#include <QWidgets>
Qt provides the QGuiApplication
class (a subclass of QCoreApplication
) to manage your application's life cycle, including the event loop required by today's GUI platforms. You've already seen QCoreApplication
, which we used for our console application in the first chapter.
You probably won't do much with QGuiApplication
, but there are two signals it offers that are good for you to know about; these are as follows:
- It emits the
applicationStateChanged
signal when the application state changes, notifying...