diff --git a/share/qtcreator/templates/wizards/projects/qtquickapplication/main.cpp b/share/qtcreator/templates/wizards/projects/qtquickapplication/main.cpp index a562da6d5d5..986dcd606f1 100644 --- a/share/qtcreator/templates/wizards/projects/qtquickapplication/main.cpp +++ b/share/qtcreator/templates/wizards/projects/qtquickapplication/main.cpp @@ -20,25 +20,9 @@ int main(int argc, char *argv[]) QGuiApplication app(argc, argv); QQmlApplicationEngine engine; - - const QUrl mainQml(QStringLiteral("qrc:/main.qml")); - - // Catch the objectCreated signal, so that we can determine if the root component was loaded - // successfully. If not, then the object created from it will be null. The root component may - // get loaded asynchronously. - const QMetaObject::Connection connection = QObject::connect( - &engine, &QQmlApplicationEngine::objectCreated, - &app, [&](QObject *object, const QUrl &url) { - if (url != mainQml) - return; - - if (!object) - app.exit(-1); - else - QObject::disconnect(connection); - }, Qt::QueuedConnection); - - engine.load(mainQml); + engine.load(QUrl(QStringLiteral("qrc:/main.qml"))); + if (engine.rootObjects().isEmpty()) + return -1; return app.exec(); }