Hello. I have a ListView tied to a QAbstractListModel in C++ by way of a QSortFilterProxyModel so the list contents can be sorted (dynamic sorting is enabled).
My problem is simple:
Say the ListView contains the following items:
0: A
1: B
2: C
B is selected, and thus highlighted, so the currentIndex is 1 and the currentItem is B. Suddenly, the list is sorted to be:
0: A
1: C
2: B
And the ListView shows this. However, the currentIndex is still 1, which means the currentItem is now C and the highlight moves from B to C.
My question is simple: what is the best way to ensure that if B is selected before the sort, B is still selected after the sort?
↧