Hi,
I am using a QSqlTableModel for a SQlite database.
The SQLite database contains a:
- Table: "ThePer"
- Columns: ID, Name, Work.
Also, I have a Tableview to display the database's content, and a button to update the content of the selected row.
When I click the button to update the 'Work' column of the selected row, thats work only the first time. And doesn't work when I want to update an other selected row.
This is a short code of my MyExample.zip:
QModelIndex TheIndex
= ui
->tableView
->selectionModel
()->currentIndex
();
TheModel->setData(TheModel->index(TheIndex.row(),2), true, Qt::EditRole);
TheModel->select();
// TheModel->submitAll();
TheDB.close();
QModelIndex TheIndex = ui->tableView->selectionModel()->currentIndex();
TheModel->setEditStrategy(QSqlTableModel::OnFieldChange);
TheModel->setData(TheModel->index(TheIndex.row(),2), true, Qt::EditRole);
TheModel->select();
// TheModel->submitAll();
TheDB.close();
To copy to clipboard, switch view to plain text mode
Thanks.
Bookmarks