Using setContextProperty with other qml files
Solved
QML and Qt Quick
-
Hellow.
I want to use setContextProperty with other qml files.#ifdef ACTIVE appEngine.rootContext()->setContextProperty("ACTIVE", QVariant(true)); #else appEngine.rootContext()->setContextProperty("ACTIVE", QVariant(false)); #endif appEngine.load(QUrl("qrc:/qml/main.qml"));
"ACTIVE" can use in main.qml.
I want to use this in sub.qml, how do I do it? -
@w-tkm said in Using setContextProperty with other qml files:
I use QQuickWidget.
I absolutely need to use QQuickWidget.QQuickWidget *view = new QQuickWidget; view->rootContext()->setContextProperty("ACTIVE", QVariant(false)); view->setSource(QUrl::fromLocalFile("myqmlfile.qml")); view->show();
-
@w-tkm said in Using setContextProperty with other qml files:
I use QQuickWidget.
I absolutely need to use QQuickWidget.QQuickWidget *view = new QQuickWidget; view->rootContext()->setContextProperty("ACTIVE", QVariant(false)); view->setSource(QUrl::fromLocalFile("myqmlfile.qml")); view->show();