This is a very strange situation. The code is small and simple
model->setTable("InputLabels");
// model->setRelation(model->fieldIndex("label_id"), QSqlRelation("Labels", "id", "text"));
model->select();
ui->tableView->setModel(model);
QSqlRelationalTableModel *model ;
model = new QSqlRelationalTableModel();
model->setTable("InputLabels");
// model->setRelation(model->fieldIndex("label_id"), QSqlRelation("Labels", "id", "text"));
model->select();
ui->tableView->setModel(model);
To copy to clipboard, switch view to plain text mode
when i run it like this i can edit my data directly in the tableView and post it with model->submitAll()
but if remove comment from setRelation line, every time i exit focus after editing data, the data in cell reverts to original value. column i edit is not the one with relation. So if i use setRelation i am unable to edit data in tableView. Am i missing something or it is "a bug".
anyone with similar problem?
I also wanted to make the relation column read only, but that is another story
Bookmarks