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():
{
if (parent.isValid())
return 0;
if (d->strategy == OnManualSubmit) {
for (QSqlTableModelPrivate::CacheMap::ConstIterator it = d->cache.constBegin();
it != d->cache.constEnd(); ++it) {
if (it.value().op == QSqlTableModelPrivate::Insert)
++rc;
}
} else if (d->insertIndex >= 0) {
++rc;
}
return rc;
}
int QSqlTableModel::rowCount(const QModelIndex &parent) const
{
Q_D(const QSqlTableModel);
if (parent.isValid())
return 0;
int rc = QSqlQueryModel::rowCount();
if (d->strategy == OnManualSubmit) {
for (QSqlTableModelPrivate::CacheMap::ConstIterator it = d->cache.constBegin();
it != d->cache.constEnd(); ++it) {
if (it.value().op == QSqlTableModelPrivate::Insert)
++rc;
}
} else if (d->insertIndex >= 0) {
++rc;
}
return rc;
}
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?
Bookmarks