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 Qt Widgets should include the QWidgets header as one of its headers. You might also need to include the header files for individual widgets, such as QButton and QMenuBar:
#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 Chapter 1, Getting Started with Qt Creator.
You probably won't do much with QGuiApplication, but there are two signals it offers that are good for...