I've discovered that inside calling index() second time:

sqltm->setData(sqltm->index(0,tab_col::Col1),data3);

hasIndex() returns "fail" because second time rowCount() inside hasIndex():

Qt Code:
  1. int QSqlTableModel::rowCount(const QModelIndex &parent) const
  2. {
  3. Q_D(const QSqlTableModel);
  4.  
  5. if (parent.isValid())
  6. return 0;
  7.  
  8. int rc = QSqlQueryModel::rowCount();
  9. if (d->strategy == OnManualSubmit) {
  10. for (QSqlTableModelPrivate::CacheMap::ConstIterator it = d->cache.constBegin();
  11. it != d->cache.constEnd(); ++it) {
  12. if (it.value().op == QSqlTableModelPrivate::Insert)
  13. ++rc;
  14. }
  15. } else if (d->insertIndex >= 0) {
  16. ++rc;
  17. }
  18. return rc;
  19. }
To copy to clipboard, switch view to plain text mode 

-

for (QSqlTableModelPrivate::CacheMap::ConstIterator it = d->cache.constBegin();
it != d->cache.constEnd(); ++it)

didn't increment rc.

So index return correct value just on first call, when there is INSERT row in cache.
Is that a bug?