I have a table that supposed to record changes, deletion and additions to the Database via QT application. But by looking at the data it seems that only records the first selection for the table. Everything works with the addition, deletion or changes is just the recording of the action correctly.
I have a table that is constructed this way:
model = new QSqlTableModel(this);
model->setTable("user");
model->setEditStrategy(QSqlTableModel::OnManualSubmit);
model->select();
At the save button I have the following:
void UserInformation::on_save_clicked()
{
model->submitAll();
QString lastCommand=model->query().lastQuery();
qDebug() << lastCommand;
QSqlQuery query;
query.prepare("insert into access (iduser,action) values (:iduser, :action)");
query.bindValue(":iduser",workData->userID);
query.bindValue(":action",lastCommand);
query.exec();
}
This is the result, even when i change or add a record:
"SELECT `iduser`, `email`, `passwd`, `privilege`, `remainder`, `active` FROM user"
I can see on the database the changes being posted.
Is there anyway to get the last command to the database?