main.cpp 578 B

1234567891011121314151617181920
  1. #include <QGuiApplication>
  2. #include <QQmlApplicationEngine>
  3. int main(int argc, char *argv[])
  4. {
  5. QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
  6. QGuiApplication app(argc, argv);
  7. QQmlApplicationEngine engine;
  8. const QUrl url(QStringLiteral("qrc:/main.qml"));
  9. QObject::connect(&engine, &QQmlApplicationEngine::objectCreated,
  10. &app, [url](QObject *obj, const QUrl &objUrl) {
  11. if (!obj && url == objUrl)
  12. QCoreApplication::exit(-1);
  13. }, Qt::QueuedConnection);
  14. engine.load(url);
  15. return app.exec();
  16. }