[SailfishDevel] ListModel sorting in QML

Tigre-Bleu devel at tigre-bleu.net
Sun Nov 17 12:39:15 UTC 2013


Hi,

I have a ListView which loads a model from JSON with JSONListModel. The model contains items and category ids, but is not sorted by category.

What I wand to do is to display the items sorted by categories in the ListView. I have put a section.property in the ListView but it is working only half as expected because it is not sorting the model.

For instance, if my model content is:

Item1 - Category1
Item2 - Category1
Item3 - Category2
Item4 - Category3
Item5 - Category3
Item6 - Category1

Then my ListView will display:

Category1
  Item1
  Item2
Category2
  Item3
Category3
  Item4
  Item5
Category1
  Item6

Of course I would like Item6 to be set between Item2 and Item3.

How is possible to do that in QML? I would like to avoid manually iterating on all the items to re-order.

Thanks,

Antoine


More information about the Devel mailing list