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/example/app/main.cpp

37 lines
1.0 KiB
C++
Raw Permalink Normal View History

2021-01-28 17:06:40 +08:00
#include <QGuiApplication>
2021-06-08 11:43:34 +08:00
#include <QMovie>
2021-01-28 17:06:40 +08:00
#include <QQmlApplicationEngine>
2021-02-02 20:42:37 +08:00
#include <QQmlContext>
2021-02-04 16:59:58 +08:00
#include "demo/DoricDemoBridge.h"
#include "widget/flex/FlexLayoutService.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;
qmlRegisterType<FlexLayoutService>("pub.doric.widget", 1, 0,
"FlexLayoutService");
2021-05-06 10:01:56 +08:00
// const QUrl url(QStringLiteral("qrc:/test-layout.qml"));
2021-02-04 16:59:58 +08:00
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
auto context = engine.rootContext();
2021-06-08 11:43:34 +08:00
DoricDemoBridge *demoBridge = new DoricDemoBridge(&engine);
2021-02-04 16:59:58 +08:00
context->setContextProperty("demoBridge", demoBridge);
2021-04-25 14:38:58 +08:00
qDebug() << QMovie::supportedFormats();
2021-02-04 16:59:58 +08:00
engine.load(url);
2021-02-04 16:59:58 +08:00
return app.exec();
2019-12-04 15:51:46 +08:00
}