#include #include #include int main(int argc, char *argv[]) { QGuiApplication app(argc, argv); QQmlApplicationEngine engine; // This line is auto-generated const QUrl url(QStringLiteral("qrc:/your-app/Main.qml")); // This block of code in main.cpp is auto-generated by Qt when // you create a QML-based application using tools like Qt Creator. // It sets up a safety mechanism to gracefully exit the // application if the QML engine fails to load the main QML file. QObject::connect( &engine, &QQmlApplicationEngine::objectCreated, &app, [url](QObject *obj, const QUrl &objUrl) { if (!obj && url == objUrl) QCoreApplication::exit(-1); }, Qt::QueuedConnection); engine.load(url); return app.exec(); }