Returning to the Qt-based example project from Chapter 8, Example - Linux-Based Infotainment System, we can now compare its main function to the preceding command-line-only version to see what changes once we add a GUI to the project:
#include "mainwindow.h" #include <QApplication> int main(int argc, char *argv[]) { QApplication a(argc, argv); MainWindow w; w.show(); return a.exec(); }
The most obvious change here is that we use QApplication instead of QCoreApplication. The other big change is that we do not use a completely custom class, but one that derives from QMainWindow:
#include <QMainWindow> #include <QAudioRecorder> #include <QAudioProbe> #include <QMediaPlayer> namespace Ui { class MainWindow; } class ...