I have a QListView pulling data from a QSQLTableModel.
Upon a user clicking an 'Add' button, I add a new item and open it for editing:
QSqlTableModel *tblModel= qobject_cast<QSqlTableModel *>(ui->listView->model());
if(tblModel->insertRow(tblModel->rowCount()))
ui->listView->edit(tblModel->index(tblModel->rowCount()-1, 1));
But once the user is done editing the new value, the selection of listView is lost. I can't find a signal on QListView or QSQLTableModel to handle when and edit has finished for me to 'restore' the selection.
Is there a way I can make sure the selection is kept?