If you call select() the whole model is reset. I suggest you do the update manually using the model interface (QAbstractItemModel::setData()). Then your selection will be kept. And it will be much simpler to do, because you'll be operating on model indexes directly and not mapping them to database rows back and forth.
newnames << ...
int curr = 0;
foreach
(QModelIndex index, view
->selectionModel
()->selectedIndexes
()){ view->model()->setData(index, newnames[curr++], Qt::DisplayRole);
}
QStringList newnames;
newnames << ...
int curr = 0;
foreach(QModelIndex index, view->selectionModel()->selectedIndexes()){
view->model()->setData(index, newnames[curr++], Qt::DisplayRole);
}
To copy to clipboard, switch view to plain text mode
Bookmarks