[SailfishDevel] Wrap data in Item to get notifiable properties ?

François K. daitheflu at free.fr
Tue Dec 2 10:28:51 UTC 2014


Hi,

@Lucien : thanks again for your help. I'm starting to owe you a lot :)

----- Mail original -----
 
> The best way to do this is to use QML ListModel. Instead of loading
> the properties in a JS object, you can load them as model properties
> (via
> http://qt-project.org/doc/qt-5/qml-qtqml-models-listmodel.html#set-method).
> Accessing the properties would be done via "model":
> 
> DetailItem {
>     label: qsTr("MyProp")
>     value: model.myProp
> }

I see. Since I already have a ListModel for the previous view (basically, a list), I'm now wondering if I'd best :

  1. Load everything in the ListModel and just go on with it (but what about memory consumption if the ListModel is big ?) ;

or :

  2. Load the minimum amount of data in the ListModel for the ListView, and when I enter the DetailsView, load the additional data and modify the ListModel via set(...) or setProperty(...).


Is there a preferred way ?


> If you don't want to use a ListModel, prefer using QtObject instead
> of Item. QtObject provides a non-graphical component to store
> properties, unlike Item that implies having a "box" (x, y, width,
> height, anchors etc.)

Oh yes, sure ! How could I miss that one ? :(
I think I'll try to stick with the ListModel, it'll probably solve another issue :)


Best regards,

-- 
François


More information about the Devel mailing list