This repository has been archived on 2024-07-22. You can view files and clone it, but cannot push or open issues or pull requests.
Doric/doric-Qt/doric/main.cpp

28 lines
771 B
C++
Raw Normal View History

2021-01-28 17:06:40 +08:00
#include <QGuiApplication>
#include <QQmlApplicationEngine>
2021-02-02 20:42:37 +08:00
#include <QQmlContext>
2021-02-04 16:59:58 +08:00
#include "demo/DoricDemoBridge.h"
2019-12-04 15:51:46 +08:00
2021-02-04 16:59:58 +08:00
int main(int argc, char *argv[]) {
QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
2019-12-04 16:44:30 +08:00
2021-02-04 16:59:58 +08:00
QGuiApplication app(argc, argv);
2019-12-04 15:51:46 +08:00
2021-02-04 16:59:58 +08:00
QQmlApplicationEngine engine;
const QUrl url(QStringLiteral("qrc:/main.qml"));
QObject::connect(
&engine, &QQmlApplicationEngine::objectCreated, &app,
[url](QObject *obj, const QUrl &objUrl) {
2021-01-28 17:06:40 +08:00
if (!obj && url == objUrl)
2021-02-04 16:59:58 +08:00
QCoreApplication::exit(-1);
},
Qt::QueuedConnection);
2021-01-28 17:06:40 +08:00
2021-02-04 16:59:58 +08:00
DoricDemoBridge *demoBridge = new DoricDemoBridge();
auto context = engine.rootContext();
context->setContextProperty("demoBridge", demoBridge);
engine.load(url);
return app.exec();
2019-12-04 15:51:46 +08:00
}