-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
35 lines (27 loc) · 869 Bytes
/
Copy pathmain.cpp
File metadata and controls
35 lines (27 loc) · 869 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
29
30
31
32
33
34
35
#include "foo.h"
#include "manager.h"
#include <QtQml>
#include <QGuiApplication>
#include <QQmlApplicationEngine>
// Second, define the singleton type provider function (callback).
static QObject *manager_provider(QQmlEngine *engine, QJSEngine *scriptEngine);
int main(int argc, char *argv[])
{
QGuiApplication app(argc, argv);
// Must be new in heap
Manager* manager = new Manager;
qDebug("manager : %x\n", &manager);
qmlRegisterSingletonType<Manager>("Ho0", 1, 0, "Manager", manager_provider);
QQmlApplicationEngine engine;
engine.load(QUrl(QStringLiteral("qrc:/main.qml")));
Foo foo;
Q_UNUSED(foo);
return app.exec();
}
static QObject *manager_provider(QQmlEngine *engine, QJSEngine *scriptEngine)
{
Q_UNUSED(engine)
Q_UNUSED(scriptEngine)
Manager* instance = Manager::getInstance();
return instance;
}