diff options
Diffstat (limited to 'main.cpp')
| -rw-r--r-- | main.cpp | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/main.cpp b/main.cpp new file mode 100644 index 0000000..c0aab91 --- /dev/null +++ b/main.cpp @@ -0,0 +1,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(); +} |
