In QSqlRelationalTableModel->setRelation(...), how can I specify a combination of fields to display?
Solved
General and Desktop
-
Hi
Not 100% sure what u ask to do. Sounds like u want to take data from model and hook to combobox.
If that is correct. have a look at
http://doc.qt.io/qt-5.5/qdatawidgetmapper.html#detailsor do u mean like
model->setTable("employee");
model->setRelation(2, QSqlRelation("city", "id", "name")); -
It's more like the second option, using model->setRelation(...). the thing is, in QSqlRelation, we can choose to display only one column (in your example: "name") and what I need is the flexibility to display a computed column (without adding computed columns at the database)...
Is this clear?
-
Hi,
Since it's only for display, you could use a QSqlQueryModel to populate the combo box with the computed values.