Ok, solved. I was hiding the primary key column from the database/model in the view and this was the field the search was based on.
Now if I setColumnHidden(0,FALSE) when starting the search, then setColumnHidden(0,TRUE) after the scrollTo, it works fine.
For the benefit of anyone else needing this, here is the code that works:
if (vidx.isValid()) {
view->setColumnHidden(0, FALSE);
view->setColumnHidden(0, TRUE);
}
if (vidx.isValid()) {
view->setColumnHidden(0, FALSE);
view->selectionModel()->select(vidx, QItemSelectionModel::Select | QItemSelectionModel::Rows);
view->scrollTo(vidx, QAbstractItemView::EnsureVisible);
view->setColumnHidden(0, TRUE);
}
To copy to clipboard, switch view to plain text mode
Bookmarks