Hi everybody,

I have a strange problem with QT's table model/view. I want to use subclass of QSortFilterProxyModel to implement sorting on a table. According to QT's reference, I do like this:
Qt Code:
  1. MyDataList list;
  2. //initialize of list
  3. MyTableModel* model = new MyTableModel(list);
  4. MySortFilterProxyModel* proxyModel = new MySortFilterProxyModel;
  5. proxyModel->setSourceModel(model);
To copy to clipboard, switch view to plain text mode 

The table view's sortingEnabled property is set to be true. When I click the horizontal header of the table, sorting behaves correctly except the row index is no longer starting from 1 and increase by 1. For example, before sorting, the row index is 1,2,3 from top to bottom, and after sorting, row index becomes 2,3,1. It seems row index is fixed to the row, which is not my expectation. What I want is the table behaves just like Microsoft Excel, row index does not change when sorting. Same problem occurs with filtering.

I didn't override any virtual function in MySortFilterProxyModel. If I don't use MySortFilterProxyModel and implement source model's sort() method, I can get the right behavior. I am not sure if it is a problem with QSortFilterProxyModel, or some mistake in my implementation. Any suggestion on this?

Thank you very much!