-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathmain.cpp
More file actions
39 lines (36 loc) · 1.21 KB
/
main.cpp
File metadata and controls
39 lines (36 loc) · 1.21 KB
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
33
34
35
36
37
38
39
#include <QFont>
#include <QFontDatabase>
#include <QGuiApplication>
#include <QQmlApplicationEngine>
#include <QQmlContext>
#include "src/globals.h"
int main(int argc, char *argv[])
{
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
#endif
QGuiApplication app(argc, argv);
// Load the font
int fontId = QFontDatabase::addApplicationFont(":/fonts/he1ma.ttf");
if (fontId != -1) {
QStringList fontFamilies = QFontDatabase::applicationFontFamilies(fontId);
if (!fontFamilies.isEmpty()) {
app.setFont(QFont(fontFamilies.at(0))); // Use the first available family
}
}
QQmlApplicationEngine engine;
const QUrl url(QStringLiteral("qrc:/main.qml"));
qmlRegisterType<PageEnum>("Hema", 1, 0, "PageEnum");
qmlRegisterSingletonType(QUrl(QStringLiteral("qrc:/Style.qml")), "Style", 1, 0, "Style");
QObject::connect(
&engine,
&QQmlApplicationEngine::objectCreated,
&app,
[url](QObject *obj, const QUrl &objUrl) {
if (!obj && url == objUrl)
QCoreApplication::exit(-1);
},
Qt::QueuedConnection);
engine.load(url);
return app.exec();
}