Call QSqlTableModel::insertRows(), call setData() a number of times to set what you want in the new row (don't set the id column), move to another row or submitAll() the row (depends on edit strategy). This is all straight out of the manual, nothing tricky.
This method doesn't work.
For now I use:
void DBEngine
::beforeInsertRec(QSqlRecord &record
) {
record.setGenerated(0, false);
}
void DBEngine::beforeInsertRec(QSqlRecord &record)
{
record.setGenerated(0, false);
}
To copy to clipboard, switch view to plain text mode
slot connected to beforeInsert(QSqlRecord &record) signal to set ID field to not be generated in sql query.
I've found this solution in this forum.
Thanks.
Bookmarks