Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Native Development

Reply
Developer
Brennan12325
Posts: 205
Registered: ‎05-15-2012
My Device: None

Is it possible to edit a ListView data model in QML

I asked a different question previously, here: http://supportforums.blackberry.com/t5/Cascades-Development/QML-ListView-update-item-on-data-model-c...

 

However, it strikes me that the fundamental problem is whether you can edit a data model at all, in QML.

 

Looking at the ListView docs (believe me, I've read them over numerous times) it looks like it can't be done using ListItemComponent for the visual model.

 

Can anyone confirm this is impossible? Am I completely unable to store any sort of state with an item if my list is in QML and displayed via ListItemComponent? Can I add a new element to the datamodel somehow, perhaps? I just need to store a state in some way.

----------------------
Check out my app, Alien Flow for reddit

And of course, like my post if you found it helpful or informative!
Developer
Brennan12325
Posts: 205
Registered: ‎05-15-2012
My Device: None

Re: Is it possible to edit a ListView data model in QML

I suspect the answer to my question is no.

 

I solved my problem by passing in the class that controlled the lists data model as a context property. Using that class I called a function from the QML list item that was defined as a Q_INVOKABLE function in the class. This function modifies the data model appropriately. I have found no way to modify the data model dirrectly from QML.

----------------------
Check out my app, Alien Flow for reddit

And of course, like my post if you found it helpful or informative!
Developer
Zmey
Posts: 1,512
Registered: ‎12-18-2012
My Device: PlayBook, Z10, DAC

Re: Is it possible to edit a ListView data model in QML

It's possible. I responded to your original question, please try if it works:
http://supportforums.blackberry.com/t5/Cascades-Development/QML-ListView-update-item-on-data-model-c...


Andrey Fidrya, @zmeyc on twitter