QSqlTableModel: How can I finish adding new row to the table with [Enter] key?
-
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.@void MyTab::New()
{
int row = model->rowCount();
if(!model->insertRow(row))
{
if(model->lastError().isValid()) {
QString errt = model->lastError().text();
QMessageBox::critical(0, QObject::tr("DB Error"),errt);
QLOG_ERROR()<<QString("MyTab::New() -err: %1.").arg(errt);
}
else {
model->select();
QLOG_WARN()<<QString(MyTab::New() -insertRow == FALSE, but no error."); //happens sometimes
}
};
QModelIndex index = model->index(row, 0);
view->setCurrentIndex(index);
view->edit(index);
}@ -
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)