Variables in QML?
-
No, you cannot. You have to export your variable from C++ layer down to the QML by using QDeclarativeContext::setContextProperty().
-
Use properties. See http://developer.qt.nokia.com/doc/qt-4.7/propertybinding.html
-
AlterX,
I think this is the best way to solve the problem. I am developing stuff in this direction and what is really helpful is js associated with the usage of the loader element.
You can create a QML document of the type
@
import "MyScript.js" as ScriptItem {
id: myItem
...
Loader {
id: myLoader
[... set loader properties ...]
source: Script.getDocumentToLoad()
}
}
@
Then in the .js script you create the function like
@
function getDocumentToLoad() {if(myTimeOfDay() > 12) { return "AfternoonWidget.qml" else return "MorningWidget.qml"
}
@Hope this can help you.
-
@Alicemirror: Yes it is... ;-)