When we looked at the QML application, we focused purely on the QML side of things, but if you look at the HelloFromQML project and expand the sources area, you will find that there is a main.cpp file. Let's take a look at its contents:
#include <QGuiApplication>
#include <QQmlApplicationEngine>
int main(int argc, char *argv[])
{
QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
QGuiApplication app(argc, argv);
QQmlApplicationEngine engine;
engine.load(QUrl(QStringLiteral("qrc:/main.qml")));
if (engine.rootObjects().isEmpty())
return -1;
return app.exec();
}
That looks a lot like the standard main.cpp file for a Qt Widgets application, but instead of a MainWindow class being instantiated, a QQmlApplicationEngine is being created.
QML code is run in a QQmlEngine. QQmlApplicationEngine...