[solved] QT add custom table view
-
I am working on application that used QSqlTableModel and tableview. my model contain columns quantity and unit price. now i want to show in tableview column named amount that is equal to quantity X unit price. is there any way to it using custom delegates or any otherway? and also when i add new row to table it should automatically fill amount column.
-
Hi,
You can use a proxy model which will return on additional column, in the data function you'll reimplement, return the amount like you want.
You control the row adding part, so it's up to you to fill the values you want in.
-
hi Thank you for your solution. I am new to qt and programming. I have looked for examples which subclass proxymodel but i could not find anything. can you show me how to subclass proxymodel. and also is their any possibility to use proxy model to join two qsqltablemodel?
-
Hi,
QSortFilterProxyModel and QIdentityProxyModel are two good examples of proxy models.
Two QSqlTableModel ? You would need a model on top of them that would return the columnCount that is the sum of both table column count and map the index in setData/data to the right QSqlTableModel
-
Thank you. Is there any good tutorials for this? I couldn't found any good tutorials. i am new to qt.
-
The "Custom Sort/Filter Model Example" filter example in Qt's documentation comes to mind
-
Thank you for your help. I will look in to it.