Modifying a cell in TableView using QSqlQueryModel
-
-
I need to query a database and load a tableView. Most of the columns are displayed as in the database. However, one column needs to be changed from a number to a text string.
The function is very simple. How do I connect this function to the table?
Thanks
- One possibility is a
QAbstractProxyModelon top of the SQL model to which the view now attaches which maps the value to a string for the view. - Another is a
QStyedItemDelegateto do the mapping just for diaply in the view. - And a third is if the mapped strings are held in another SQL table to use a
QSqlRelationalTableModelif yourQSqlQueryModelcan be aQSqlTableModel.
- One possibility is a
-
- One possibility is a
QAbstractProxyModelon top of the SQL model to which the view now attaches which maps the value to a string for the view. - Another is a
QStyedItemDelegateto do the mapping just for diaply in the view. - And a third is if the mapped strings are held in another SQL table to use a
QSqlRelationalTableModelif yourQSqlQueryModelcan be aQSqlTableModel.
@JonB Maybe a QIdentityModel will work also.
- One possibility is a
-
@JonB Maybe a QIdentityModel will work also.
@Christian-Ehrlicher
AQIdentityProxyModelis derived fromQAbstractProxyModelper my first bullet :) Yes, one would start from aQIPMas an example of aQAPM(does the groundwork for all the identical columns) and just change the one column whose values need mapping.