I use Windows, C++ and Qt 5.11.1. I have a simple single-table SQLite database. This table "templates" contains primary key: id INTEGER PRIMARY KEY
.When I try to remove a single row in "templates" (using QSqlTableModel
), m_model.removeRow(0)
returns true and submitAll()
returns true. But the table still owns that row. I've found that Qt generated the following SQL:
DELETE FROM templates WHERE "templates"."id" IS NULL
.
I suppose that the problem is linked with QSqlRecord::isGenerated
. How can I fix this error?
As QSqlTableModel::removeRows documentation :
Deletions are submitted immediately to the database. The model retains a blank row for successfully deleted row until refreshed with select().