I have a QSqlTableModel and a QTableView. Trying to sort through the model, find a record, then scroll to it in the view.
Here is the code, where strID is a string to search for, like "89".

Qt Code:
  1. proxy.setSourceModel(model);
  2.  
  3. proxy.setFilterKeyColumn(0);
  4. proxy.setFilterFixedString(strID);
  5. vidx = proxy.mapToSource(proxy.index(0, 0));
  6.  
  7. if (vidx.isValid())
  8. {
  9. view->selectionModel()->select(vidx, QItemSelectionModel::Select | QItemSelectionModel::Rows);
  10. view->scrollTo(vidx, QAbstractItemView::EnsureVisible);
  11. }
To copy to clipboard, switch view to plain text mode 

I am having two problems.

1. If the header sort is set to column 0 ascending, and the record found has a sequential value in column 0 of more than 256, the scrollTo does not work, 256 or less and it works fine.

2. if the header sort is set to column 0 descending, and the record found has a sequential value in column 0 of 89 for example, the view scrolls to the record with 289 in column 0.

Any advice as to how to overcome these problems greatly appreciated.