I have some models that use the QAbstractItemModel rules to retrieve and provide data for a table.
My sample model has several columns and rows. Unfortunately, QtQuick widgets can only process one column. Other "columns" are added to QtQuick widgets through roles. Thus, several columns in a view correspond to one column in the model. Other model columns are ignored, as explained in this question and its answer
I thought it shouldn't be too difficult to provide an abstraction for QML that will be used on the C ++ side (like QAbstractProxyModel ), which, when querying for a row N modulo, is output from the column of the original model and extracts data from the final actual column. This would seem to work for the Grid , but will not work for the TableView , since it relies on the TableViewColumn and role names instead of using only continuous row indexes. For this, the proxy model will have to distinguish between the role from which the column of the source model is extracted.
The snippet present in the answer http://qt-project.org/forums/viewthread/41793 does this to accept QSqlTableModel , but still skips the translation of a large number of signals you can use. As I assume, if the original SQL model columnsInserted , it should translate to the dataChanged signal with the new roles selected for this column and changing the names of the available roles. QMLifyProxyModel seems to look better, but not ready and dead for 4 years. It seems.
How can we better fix this so that the two worlds work freely, according to an official recommendation? Why are QtQuick views not using the notation (row, column) that QAbstractItemModel and QTableView have already used?
source share