-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
32 lines (28 loc) · 954 Bytes
/
Copy pathmain.cpp
File metadata and controls
32 lines (28 loc) · 954 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#include <QGuiApplication>
#include <QQmlApplicationEngine>
#include <QQmlContext>
#include <QDir>
#include <QUrl>
#include "GlobalFunc.h"
int main(int argc, char *argv[])
{
// // 设置应用程序属性
// QGuiApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
// QGuiApplication::setAttribute(Qt::AA_UseHighDpiPixmaps);
QGuiApplication app(argc, argv);
QQmlApplicationEngine engine;
// 注册C++类到QML
GlobalFunc globalFunc;
engine.rootContext()->setContextProperty("globalFunc", &globalFunc);
globalFunc.registerFont("resources/remixicon.ttf");
QJsonObject varobj = globalFunc.readJsonFile("resources/config.json");
globalFunc.setVardata(varobj);
QObject::connect(
&engine,
&QQmlApplicationEngine::objectCreationFailed,
&app,
[]() { QCoreApplication::exit(-1); },
Qt::QueuedConnection);
engine.load("page/Main.qml");
return app.exec();
}