-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
28 lines (25 loc) · 1010 Bytes
/
main.cpp
File metadata and controls
28 lines (25 loc) · 1010 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
#include "Backend/metricsservice.h"
#include <QCoreApplication>
#include <QGuiApplication>
#include <QQmlApplicationEngine>
#include <QQmlContext>
int main(int argc, char *argv[]) {
QGuiApplication app(argc, argv);
QQmlApplicationEngine engine;
// Create MetricsService as a pointer and expose to QML
MetricsService *metricsService = new MetricsService(&app);
if (metricsService) {
// Register as singleton for Qt 6 modules
qmlRegisterSingletonInstance("SmartPersonalDashboard", 1, 0, "Metrics",
metricsService);
// Fallback for existing QML code using lowercase 'metrics'
engine.rootContext()->setContextProperty("metrics", metricsService);
} else {
qCritical() << "Failed to create MetricsService!";
}
QObject::connect(
&engine, &QQmlApplicationEngine::objectCreationFailed, &app,
[]() { QCoreApplication::exit(-1); }, Qt::QueuedConnection);
engine.loadFromModule("SmartPersonalDashboard", "Main");
return app.exec();
}