QSqlRelationalDelegate and QSqlRelationalTableModel::setRelation Bug ?
-
I have the tblCountry and the tblPort. Every port is on one country connected by IDCountry.
Now I want show and edit the country of every port in a tableview.Ports.setTable("tblPort"); Ports.setRelation(3, QSqlRelation(tblCountry, fieldID, fieldDesc)); ui->PortsTV->setModel(&Ports); ui->PortsTV->setItemDelegateForColumn(3, new QSqlRelationalDelegate(ui->PortsTV));
The setRelation works. I see instead of the foreign key the country name.
Editing works too: I get a dropdown-listbox with all countrys. Changing works. Is see the new country-text in the field in form of a dropbox entry
BUT: when I select an other row the dropbox dissapear (thats correct) and I should see the text configured by setRelation. BUT I see then the primary key.
So it seem after editing the setRealation has been switched off. Refreshing the grid show again the text and not the primary key.
I cannot figure out whats wrong. -
Hi,
Sounds a bit fishy, especially if it's not written in the documentation