magpie/main.cpp

32 lines
708 B
C++
Raw Normal View History

2023-11-22 23:13:33 +00:00
#include <QGuiApplication>
#include <QQmlApplicationEngine>
#include "root.h"
int main(int argc, char *argv[]) {
Root app(argc, argv);
std::cout << "Starting" << std::endl;
QQmlApplicationEngine engine;
const QUrl url(u"qrc:qml/main.qml"_qs);
QObject::connect(
&engine, &QQmlApplicationEngine::objectCreated, &app,
[&url](QObject* obj, const QUrl& objUrl) {
if (!obj && url == objUrl)
QCoreApplication::exit(-2);
},
Qt::QueuedConnection);
engine.load(url);
if (engine.rootObjects().isEmpty())
return -1;
int result;
try {
result = app.exec();
} catch (...) {
}
return result;
}