Is there a way we can use a period/dot seperator in variable names in qml for setting property/context property
-
My QML file should look something like this
@Rectangle {
id: rect
width: 500
height: 500
color: "#654321"
Text {
text: Group1.SetA.myText
anchors.centerIn: parent
}
}
@Somewhere in my C code I would like to do something like below to update the text
RootContext->setContextProperty("Group1.SetA.myText", "ValueString");
OR
myViewer->setProperty("Group1.SetA.myText", "ValueString");Is that possible ? Can we use period/dot in qml property names? If not, is there any other way ?
-
I don't think you can do that, but there are many ways to set the value.
You could use a global property and bind it to the text and then easily change it from c++ or you get the specific QML item from c++ which is not that easy I think. Depending on how often you need to do that the quick (and maybe dirty) way is to use the evaluate function of the QML engine, there you can run any valid QML code like Javascript evil function, just from c++.