In QSqlRelationalTableModel->setRelation(...), how can I specify a combination of fields to display?
I really like QSqlRelationalTableModel, but I want to specify a combination of fields (or a derived field) to display in a combobox instead of just one column values... How can I go about this?
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
or do u mean like
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?
Since it's only for display, you could use a QSqlQueryModel to populate the combo box with the computed values.