QSqlTableModel problem with set data
Unsolved
General and Desktop
-
db = QSqlDatabase::addDatabase("QSQLITE"); db.setDatabaseName("test.db"); db.open(); QSqlQuery q(db); q.prepare("CREATE TABLE IF NOT EXISTS test(id INTEGER PRIMARY KEY AUTOINCREMENT, Date_O VARCHAR(255));"); q.exec(); model = new QSqlTableModel(this, db); model->setTable("test"); model->setEditStrategy(QSqlTableModel::OnFieldChange); model->select(); ui.tableView->setModel(model); connect(ui.add_b, &QPushButton::clicked, [&](){model->insertRow(0); });
After few clicks on button inserted only one row
++ after edit fields data is not stored in table.
What could be the problem?Thanks in advance!
-
Either trigger the submit yourself or fill all fields in the row.