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