[Qt-interest] Saving changes in a QSqlRecord
Timothy Reaves
treaves at silverfieldstech.com
Sat Dec 12 01:49:53 CET 2009
I'm trying to saved the changes I'm making to a QSqlRecord using submitAll(), but the changes do not get to the database. Am I not doing something I'm supposed to? Here is the code I use:
QSqlRecord record = tableModel->record(selectedRowIndex);
if (!record.isEmpty()) {
qDebug() << "Record: " << record;
record.setValue(4, state == Qt::Checked);
qDebug() << "Record: " << record;
}else {
qDebug() << "Empty record returned!";
}
if (!tableModel->submitAll()) {
qWarning() << "Error saving data. Error is: " << tableModel->lastError();
}
qDebug() << "Record: " << record;
The qDebug() statements print out the correct data, so I know that I have the correct record, and the record reflects the change.
Any help appreciated!
More information about the Qt-interest-old
mailing list