Important: Please read the Qt Code of Conduct -

Merging two columns using QSqlTableModel/QTableView

  • I'm using a class derived from QSqlTableModel with an associated QTableView. I would like to merge two columns in the model so thay are displayed in a single column in the view.

    As an example, assume my database contains records on cars. In this database the cars' licence plate numbers are (for some reason beyond my control) stored so that the letters are separate from the numbers, e.g. the licence number ABC-123 is stored so that ABC goes into one column and 123 in another. However, in the view I would like to display the number as ABC-123 in a single column.

    What would be the best way to achieve this?

  • Create a proxy model that does that.

Log in to reply