GUI-based Qt applications

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;; 
    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 ...

Get Hands-On Embedded Programming with C++17 now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.