-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
36 lines (28 loc) · 1.02 KB
/
Copy pathmain.cpp
File metadata and controls
36 lines (28 loc) · 1.02 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
#include <QGuiApplication>
#include <QQmlApplicationEngine>
#include <QQmlContext>
#include <QtQuickControls2/QQuickStyle> // Fixed include path
#include "mqttbrokermanager.h"
#include "messagedata.h"
int main(int argc, char *argv[])
{
QGuiApplication app(argc, argv);
// Set application style to one that allows customization
QQuickStyle::setStyle("Fusion");
// Register MessageData type with QML system
qRegisterMetaType<MessageData>();
qmlRegisterType<MessageData>("MqttApp", 1, 0, "MessageData");
// Create the MQTT broker manager
MqttBrokerManager brokerManager;
QQmlApplicationEngine engine;
// Expose the broker manager to QML
engine.rootContext()->setContextProperty("brokerManager", &brokerManager);
QObject::connect(
&engine,
&QQmlApplicationEngine::objectCreationFailed,
&app,
[]() { QCoreApplication::exit(-1); },
Qt::QueuedConnection);
engine.loadFromModule("mqtt_sub_plus_brokerProcess", "Main");
return app.exec();
}