blob: c0aab919a58ba817f8349a93f0393b2fbe2583c0 (
plain) (
blame)
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
|
#include <QGuiApplication>
#include <QQmlApplicationEngine>
#include <QQmlContext>
#include <QObject>
#include <QVariant>
#include <memory>
#include "test.h"
int main(int argc, char *argv[])
{
QGuiApplication app(argc, argv);
QQmlApplicationEngine engine("qrc:/org/yachat/lib/Main.qml");
#if 0
qRegisterMetaType<Test>("Test");
qmlRegisterType<Test>("org.yachat.lib", 1, 0, "Test");
#endif
#if 1
qmlRegisterSingletonType<Test>("org.yachat.lib", 1, 0, "Test",
[](QQmlEngine *, QJSEngine *) -> QObject *
{
return std::make_unique<Test>().release();
}
);
#else
Test test;
engine.rootContext()->setContextProperty("Test", &test);
#endif
return app.exec();
}
|