Quantcast
Channel: Qt DevNet forums: Qt Quick 1283365070**
Viewing all articles
Browse latest Browse all 4972

QML ListView currentItem doesn't change after a sort

$
0
0
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?

Viewing all articles
Browse latest Browse all 4972

Trending Articles