Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
QSqlTableModel: How can I finish adding new row to the table with [Enter] key?
mstankie last edited by
How can I finish adding new row to the table with [Enter] key? Do I have to catch the key event, or is there some settings I missed?
In my app, the user can right-click the table and choose "add new row", then a new row is added with asterisk instead of number, and the left field is focused. User can then fill all cells, and hit enter in order to finish editing. But with Qt5.1 this is not enough -one has to focus other row in table...
In doc: "OnFieldChange will behave like OnRowChange for newly inserted rows"
I understand the idea that for newly inserted rows, behaviour is changed, but for the users it seems unexpected. Everyone thinks, the [Enter] key will finish editing and insert the row with new row number instead of asterisk. In Qt4.8 it worked normally, but after compiling my app in Qt5.1, it changed confusing me and the users.
int row = model->rowCount();
QString errt = model->lastError().text();
QMessageBox::critical(0, QObject::tr("DB Error"),errt);
QLOG_ERROR()<<QString("MyTab::New() -err: %1.").arg(errt);
QLOG_WARN()<<QString(MyTab::New() -insertRow == FALSE, but no error."); //happens sometimes
QModelIndex index = model->index(row, 0);
Hi and welcome to devnet,
Since it looks like a behavior change (maybe a regression), I would recommend asking on the interest mailing list. You'll find Qt's developers/maintainers there (this forum is more user oriented)