PDA

View Full Version : qtableview - selected row after add new row



stevocz
21st September 2016, 06:47
Hi.
I have QTableView with QAbstractTableModel and QSortFilterProxyModel for my custom sorting.

But when i am added row before selected row, selection on table is wrong. (before update is selected row 10, i add row at position 5, and selected row is still 10, but i need 11) When i am added row after selected row, all is OK.

How can i fix it?

qlands
21st September 2016, 10:27
I reckon the issue is with the sorting. You can use the sorting QSortFilterProxyModel to map a sort index to the index of the model. See:

mapSelectionFromSource(const QItemSelection &sourceSelection) const
mapSelectionToSource(const QItemSelection &proxySelection) const