Preventing QSortFilterProxyModel from removing colums in QTableView
-
I have a custom QTableView which displays data using a custom QSortFilterProxyModel. In the custom proxy model I have reimplemented filterAcceptsColumn which returns true based on the selected columns in the source model of the proxy. What I'm noticing is that nothing is displayed in the table view when nothing is selected in the source model, however I want the table view to display empty cells in that case. I tried to see if there is a way to fix the row and column count in the QTableView, however this is not possible. Is there any way I can achieve what I want?
-
I guess you need to return the correct amount of "rowCount()":http://qt-project.org/doc/qt-5/qabstractitemmodel.html#rowCount and "columnCount()":http://qt-project.org/doc/qt-5/qabstractitemmodel.html#columnCount to display the empty cells.
-
I made sure of that, however that doesn't solve the problem either.
-
It seems like I didn't have the headers setup correctly and that's why the columns were being removed and added based on the return value of filterAcceptsColumn. Changing it to contain a horizontal and vertical header fixed the problem.