4

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);
NG_
  • 6,895
  • 7
  • 45
  • 67
barry
  • 4,037
  • 6
  • 41
  • 68

1 Answers1

5

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.

Dielson Sales
  • 1,715
  • 1
  • 20
  • 25
  • In not able to test this yet but will this change the order of the categories or just the items within the categories? – barry Feb 03 '13 at 07:52
  • 2
    I can confirm this changes the order of the categories. Many thanks. – barry Feb 03 '13 at 21:41