[SailfishDevel] ListView vs Repeater

Oleksii Serdiuk contacts at oleksii.name
Mon Oct 13 19:10:43 UTC 2014


Hi Kris,

If I understood you right, why do you try to remove list elements 
directly from the ListVie. You should be removing them from the model 
and it will also remove components from the list.

See http://qt-project.org/doc/qt-5/qml-qtqml-models-listmodel.html

You can access ListView's model through its 'model' property:

 > listView.model.remove(index);


If you'd like to animate the removal, set 'remove' property of ListView 
(SilicaListView is based on ListView) to some transition animation.

http://qt-project.org/doc/qt-5/qml-qtquick-listview.html#remove-prop


That would be a "proper" way to do it :-)


On 10.10.2014 17:00, Krisztian Olah wrote:
>                Hi everyone,
>
>    I need some help between choosing ListView or Repeater.
> I've got a SilicaListView whose elements I want to remove(only remove,
> never add) dynamically from GUI. When I have fairly a long list
> count(~25), reaching the element with
> ListView.contentItem.children[index] is not possible for the mid to end
> of the list, probably because ListView destroys items that are not
> visible. When that happens children[index] will not refer to the same
> element as model.index and therefore I cannot call remove() on the item.
> Using a Repeater would of course prevent this, but I don't think I can
> have a RemoveAnimation and I think I would have to reset the model.
>
>    Is there another way that I didn't think of that would allow me to
> remove items from my model with animation and would allow me to have a
> list up to 1000 members(in real use it will probably be under 100) long?
>
>        Thanks in advance
>                 Kris

-- 
With best regards,
Oleksii Serdiuk

-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 4813 bytes
Desc: S/MIME Cryptographic Signature
URL: <https://lists.sailfishos.org/pipermail/devel/attachments/20141013/c6ac86c3/attachment.bin>


More information about the Devel mailing list