I’m using QItemSelectionModel with QTableView to allow the users to select rows. The problem is that when the user then clicks on a column header to sort the rows, the selection disappears and all the sorted data is displayed. How can I keep the selection, and just sort that, rather than having all the rows appear?
Thanks!
–Erin
Here is the way I ended up solving this problem:
When row selections are made, put the unique IDs of each hidden row into a list, then hide all hidden rows
Use self.connect(self.myHorizontalHeader, SIGNAL(“sectionClicked(int)”), self.keepSelectionValues) to catch the
event when a user clicks on a column header to sort the rows
In self.keepSelectionValue, go through each row and if the unique ID is in the hidden row list, hide the row
This effectively sorts and displays the non-hidden rows without displaying all the rows of the entire table.