What is the editStrategy() on the model?
This code:
#include <QtCore>
#include <QtSql>
#include <QDebug>
int main(int argc, char *argv[])
{
db.setDatabaseName(":memory:");
db.open();
query.exec("CREATE TABLE test (a INTEGER, b VARCHAR(10))");
query.exec("INSERT INTO test VALUES (1, 'One')");
query.exec("INSERT INTO test VALUES (2, 'Two')");
query.exec("INSERT INTO test VALUES (3, 'Three')");
model.setTable("test");
model.select();
// model.setEditStrategy(QSqlTableModel::OnRowChange);
qDebug() << "Starting with" << model.rowCount();
for (int i = 0; i < 20; ++i) {
qDebug() << i << model.rowCount();
model.insertRecord(-1, record);
}
return app.exec();
}
#include <QtCore>
#include <QtSql>
#include <QDebug>
int main(int argc, char *argv[])
{
QCoreApplication app(argc, argv);
QSqlDatabase db = QSqlDatabase::addDatabase("QSQLITE");
db.setDatabaseName(":memory:");
db.open();
QSqlQuery query;
query.exec("CREATE TABLE test (a INTEGER, b VARCHAR(10))");
query.exec("INSERT INTO test VALUES (1, 'One')");
query.exec("INSERT INTO test VALUES (2, 'Two')");
query.exec("INSERT INTO test VALUES (3, 'Three')");
QSqlTableModel model;
model.setTable("test");
model.select();
// model.setEditStrategy(QSqlTableModel::OnRowChange);
model.setEditStrategy(QSqlTableModel::OnManualSubmit);
qDebug() << "Starting with" << model.rowCount();
for (int i = 0; i < 20; ++i) {
QSqlRecord record = model.record();
qDebug() << i << model.rowCount();
model.insertRecord(-1, record);
}
return app.exec();
}
To copy to clipboard, switch view to plain text mode
Works as expected with one value and not the other.
Bookmarks