How to keep selection after sorting in QListView?
-
[quote author="tokafr" date="1421937685"]
I have items displayed on QListView, I have a button to sort the list but after sorting the selections is cleared. how can I keep it?
[/quote]now the question is: how do you sort? Are you calling reset()?
-
-
[quote author="tokafr" date="1421942474"]after sorting I call listVIew->reset() to update the view yes[/quote]
this is your problem. reset() implicitly tells the view to throw away all the information it has (including selection) and to retrieve it again.You should use QSortFilterProxyModel for this case then. Which acts - as the name implies - as an proxy on top of your model and just rearranges the items for sorting.