I found myself a workaround, hope it will help others.
1) the application opens a View and not a query. the view is defined as follows: "select id, nationid, region, nationid as nationid2 from regions"
2) I set the relation on the 4thcolumn:
getModel
()->setRelation
(3,
QSqlRelation("nations",
"id",
"nation"));
getModel()->setRelation(3, QSqlRelation("nations", "id", "nation"));
To copy to clipboard, switch view to plain text mode
3) On the view swap the 4th and 3rd columns:
headerView->swapSections(3, 2);
QHeaderView *headerView = view->horizontalHeader();
headerView->swapSections(3, 2);
To copy to clipboard, switch view to plain text mode
4) After I get the record for insert/update I delete the lookup columns:
int index = record.indexOf("nation");
if (index>=0){
record.remove(index);
}
int index = record.indexOf("nation");
if (index>=0){
record.remove(index);
}
To copy to clipboard, switch view to plain text mode
It is an awful workaround but it works.
bye
Mirko
Bookmarks