[SailfishDevel] Wrap data in Item to get notifiable properties ?
François K.
daitheflu at free.fr
Tue Dec 2 09:31:46 UTC 2014
Hi,
I'm writing a small app for SailfishOS in JS + QML (I don't know C++ so please don't tell me to do this in C++).
I'm getting data from LocalStorage and hence get a Javascript Object with its own properties. Let's call it myObj.
Then I bind some field in a view to these properties :
DetailItem {
label: qsTr("MyProp")
value: myObj.myProp
}
Now, if I update myObj.myProp, the value of the DetailItem doesn't get updated.
For what I understand, this is normal because the properties of my Javascript Object (myObj) aren't notifiable and thus, QML doesn't know it has been updated.
To fix this, I wonder if it's OK to wrap my JS object into a QML Item. This would give me notifiables properties and would certainly allow me to get working bindings.
What do you think about this ? Is it OK ?
Thanks a lot for your help,
Best wishes,
--
François
More information about the Devel
mailing list