Using setContextProperty with other qml files
-
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? -
@KroMignon
I use QQuickWidget.
I absolutely need to use QQuickWidget.
I want to use ACTIVE in the onClick of the button in itBut, I got Error
[ReferenceError: ACTIVE is not defined]@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();
-
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:
"ACTIVE" can use in main.qml.
Why do you mean
ACTIVE
is only usable bymain.qml
?ACTIVE is for all items in rootContext() available. Not only main.qml.
-
@w-tkm said in Using setContextProperty with other qml files:
"ACTIVE" can use in main.qml.
Why do you mean
ACTIVE
is only usable bymain.qml
?ACTIVE is for all items in rootContext() available. Not only main.qml.
@KroMignon
I use QQuickWidget.
I absolutely need to use QQuickWidget.
I want to use ACTIVE in the onClick of the button in itBut, I got Error
[ReferenceError: ACTIVE is not defined] -
@KroMignon
I use QQuickWidget.
I absolutely need to use QQuickWidget.
I want to use ACTIVE in the onClick of the button in itBut, I got Error
[ReferenceError: ACTIVE is not defined]@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();
@KroMignon
OK, It can do it.
Thanks!