I have it on my main file:
#include <QGuiApplication>
#include <QQmlApplicationEngine>
#include <QDebug>
#include <keppoxd.h>
#include <siema.h>
#include <QQmlContext>
#include <QQmlApplicationEngine>
int main(int argc, char *argv[])
{
QGuiApplication app(argc, argv);
siema siema;
keppoxd keppo;
keppo.siema = &siema;
QQmlApplicationEngine engine;
const QUrl url
(QStringLiteral
("qrc:/main.qml"));
QObject::connect(&engine,
&QQmlApplicationEngine
::objectCreated,
if (!obj && url == objUrl)
}, Qt::QueuedConnection);
engine.load(url);
QQmlContext *ctx = engine.rootContext();
ctx->setContextProperty("Siemaqml", &siema);
ctx->setContextProperty("Keppoqml", &keppo); // HERE
return app.exec();
}
#include <QGuiApplication>
#include <QQmlApplicationEngine>
#include <QDebug>
#include <keppoxd.h>
#include <siema.h>
#include <QQmlContext>
#include <QQmlApplicationEngine>
int main(int argc, char *argv[])
{
QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
QGuiApplication app(argc, argv);
siema siema;
keppoxd keppo;
keppo.siema = &siema;
QQmlApplicationEngine engine;
const QUrl url(QStringLiteral("qrc:/main.qml"));
QObject::connect(&engine, &QQmlApplicationEngine::objectCreated,
&app, [url](QObject *obj, const QUrl &objUrl) {
if (!obj && url == objUrl)
QCoreApplication::exit(-1);
}, Qt::QueuedConnection);
engine.load(url);
QQmlContext *ctx = engine.rootContext();
ctx->setContextProperty("Siemaqml", &siema);
ctx->setContextProperty("Keppoqml", &keppo); // HERE
return app.exec();
}
To copy to clipboard, switch view to plain text mode
Bookmarks