If rows were inserted by tableModel.insertRow(), then reset() does not work for me to update the table (but it works if inserting by a QSqlQuery)

Example below:
  • rowCount is only correct on line 18, after re- setTable(...)
  • select() is sufficient if I uncomment line 2 and remove rows 3 - 8 (row count correct on line 14)

Qt Code:
  1. qDebug() << "original row count" << tableModel->rowCount();
  2. //ok = sqlQuery.exec(QLatin1String("INSERT INTO Table1(Details) VALUES ('item added by query');"));
  3. ok = tableModel->insertRow(0, QModelIndex());
  4. Q_ASSERT(ok);
  5. QSqlRecord record = tableModel->record(0); // retrieve inserted record that is empty
  6. record.setValue(3, QLatin1String("item added by insertRow and setRecord"));
  7. ok = tableModel->setRecord(0, record); // record is no longer empty*/
  8. Q_ASSERT(ok);
  9. ok = tableModel->submitAll();
  10. Q_ASSERT(ok);
  11. qDebug() << "tableModel not yet updated, row count still" << tableModel->rowCount();
  12. ok = tableModel->select();
  13. Q_ASSERT(ok);
  14. qDebug() << "after tableModel->select(), but row count still" << tableModel->rowCount();
  15. tableModel->setTable(QLatin1String("Table1"));
  16. ok = tableModel->select();
  17. Q_ASSERT(ok);
  18. qDebug() << "row count only now increased" << tableModel->rowCount();
To copy to clipboard, switch view to plain text mode 

Is this behaviour expected?