Hi all!
I have some objects that I create dynamically in QML, and I would like to bind some of these objects' properties to properties of static objects.
I have used a ListModel to manage the dynamically created objects as suggested here.
Using this ListModel I have no problem looping through all the objects and accessing them, but I can't figure out how to bind their properties to other objects.
The same site suggests using the Binding component, but I do not understand how to use it.
Without the Binding component, I have tried this:
for (var i = 0; i < listModel.count; ++i)
{
var dynObj = listModel.get(i).obj // Gives me access to the object
dynObj.someProperty = Qt.binding(function() {return staticObject.otherProperty}) // I want this to work
}
for (var i = 0; i < listModel.count; ++i)
{
var dynObj = listModel.get(i).obj // Gives me access to the object
dynObj.someProperty = Qt.binding(function() {return staticObject.otherProperty}) // I want this to work
}
To copy to clipboard, switch view to plain text mode
This sets the value of dynObj.someProperty to staticObject.otherProperty at the time this call is made, but when otherProperty changes later on QML complains about "Something related to the property not being available, I dont' remember of the top of my head, beacuse I'm writing this at home and I do not have access to the code at this moment."
Any ideas?
Bookmarks