I have a GroupDataModel
of items and use this to populate a ListView
. Each item has a category, which can be either "TV" or "Cinema". I set "category" as a sorting key and the ListView
displays the items grouped into categories.
However, the order of categories is "Cinema" then "TV". I need them to be in the other order: "TV" then "Cinema".
Is this possible?
Code:
GroupDataModel* results = new GroupDataModel();
results->setGrouping(ItemGrouping::ByFullValue);
QStringList sortingKeys;
sortingKeys.append("category");
results->setSortingKeys(sortingKeys);
You can reverse the sorting using the method setSortedAscending(bool ascending)
. If you set it to false
, the items are sorted in descending order, if true
, they are sorted in ascending order.