FluentUI/example/main.cpp

39 lines
1.3 KiB
C++
Raw Normal View History

2023-02-24 18:44:29 +08:00
#include <QGuiApplication>
#include <QQmlApplicationEngine>
2023-03-03 18:19:48 +08:00
#include <QQmlContext>
2023-03-05 23:39:13 +08:00
#include <QDir>
#include <QProcess>
2023-03-02 18:21:43 +08:00
#include "InstallHelper.h"
2023-02-26 23:47:07 +08:00
2023-03-05 23:39:13 +08:00
QMap<QString, QVariant> properties(){
QMap<QString, QVariant> map;
map["installHelper"] = QVariant::fromValue(QVariant::fromValue(InstallHelper::getInstance()));
return map;
}
2023-02-24 18:44:29 +08:00
int main(int argc, char *argv[])
{
2023-03-02 18:21:43 +08:00
QCoreApplication::setOrganizationName("ZhuZiChu");
QCoreApplication::setOrganizationDomain("https://zhuzichu520.github.io");
QCoreApplication::setApplicationName("FluentUI");
2023-03-03 18:19:48 +08:00
QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
2023-02-24 18:44:29 +08:00
QGuiApplication app(argc, argv);
QQmlApplicationEngine engine;
2023-03-05 23:39:13 +08:00
QMapIterator<QString, QVariant> iterator(properties());
while (iterator.hasNext()) {
iterator.next();
QString key = iterator.key();
QVariant value = iterator.value();
engine.rootContext()->setContextProperty(key,value);
}
engine.rootContext()->setContextProperty("properties",properties());
2023-02-26 23:47:07 +08:00
const QUrl url(QStringLiteral("qrc:/App.qml"));
QObject::connect(&engine, &QQmlApplicationEngine::objectCreated,
&app, [url](QObject *obj, const QUrl &objUrl) {
if (!obj && url == objUrl)
QCoreApplication::exit(-1);
}, Qt::QueuedConnection);
engine.load(url);
2023-02-24 18:44:29 +08:00
return app.exec();
}