-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
41 lines (32 loc) · 1.11 KB
/
main.cpp
File metadata and controls
41 lines (32 loc) · 1.11 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
40
41
#include <QGuiApplication>
#include <QQmlApplicationEngine>
#include <QCoreApplication>
#include <QObject>
#include <QDebug>
#include <QQmlContext>
#include <QtDBus/QDBusInterface>
#include <QtDBus/QDBusMetaType>
#include "Models/UsbGuardDevicesmodel.h"
#include "UsbGuardManager.h"
int main(int argc, char *argv[])
{
QGuiApplication app(argc, argv);
// 1. Instantiate the Model
UsbGuardDevicesModel* devicesModel = new UsbGuardDevicesModel(&app);
// 2. Instantiate the Manager
UsbGuardManager* manager = new UsbGuardManager(devicesModel, &app);
// 3. Set up the QML Engine
QQmlApplicationEngine engine;
// 4. Expose the Model to QML using a Context Property
// This is the line that caused the error (line 39 in your project):
engine.rootContext()->setContextProperty("usbDevicesModel", devicesModel);
// 5. Load the QML source
QObject::connect(
&engine,
&QQmlApplicationEngine::objectCreationFailed,
&app,
[]() { QCoreApplication::exit(-1); },
Qt::QueuedConnection);
engine.loadFromModule("UsbGuardGUI", "Main");
return app.exec();
}