Reading data after submit returns wrong values
-
This is my actual code:
void DialogEdit::saveBoard(int *row, int *id) { *row = _modelBoards->rowCount(); qDebug() << _modelBoards->insertRow(*row); qDebug() << _modelBoards->setData(_modelBoards->index(*row, MODEL_BOARDS_COL_NAME), ui->txtName->text()); qDebug() << _modelBoards->setData(_modelBoards->index(*row, MODEL_BOARDS_COL_DESC), ui->txtDesc->text()); qDebug() << _modelBoards->submitAll(); qDebug() << _modelBoards->select(); *id = _modelBoards->data(_modelBoards->index(*row, MODEL_BOARDS_COL_ID)).toInt(); Q_ASSUME(*id > 0); }The model is an
QSqlTableModelwith the edit strategy set toOnManualSubmit.
Sometimes, it happens thatidis read as 0, while in the database has the correct value (id INTEGER PRIMARY KEY).
All the methods returntrue- I can see the correct value in the db (using DB Browser for SQLite).As far as I understand
select()is a syncrhonous function, so when it returns the model should be already update.
Is there anything other I need to do before read the data?Qt 5.12.5 under Win7
-
Hi,
Since it's "sometimes", did you determine if that happens when your system is under pressure doing some heavy tasks ?
-
Hi,
Since it's "sometimes", did you determine if that happens when your system is under pressure doing some heavy tasks ?
-
Does it also happen if you put the database in memory ?