The sql delete command has much the same syntax as a select query.
Assuming that your table has a primary key (ID) as the first element on each row, you could try something like
QString ID
= model
->data
(model
->index
(TableView
->selectionModel
()->currentIndex
().
row(),
0)).
toString();
query.prepare("SELECT FROM table WHERE id = ?"); // or SELECT * FROM
query.addBindValue(ID);
query.exec();
QString ID = model->data(model->index(TableView->selectionModel()->currentIndex().row(),0)).toString();
QSqlQuery query;
query.prepare("SELECT FROM table WHERE id = ?"); // or SELECT * FROM
query.addBindValue(ID);
query.exec();
To copy to clipboard, switch view to plain text mode
Once you are happy that the correct row is being selected for deletion, substitute DELETE for SELECT in the above query. Please note I have not tested this but in theory it should work.
There is probably a more elegant way to do this, I'll leave that to you!
Bookmarks