QSortFilterProxyModel: problem with columnCount()
-
Hi, I've a QTreeView that shows a QAbstractItemModel through a QSortFilterProxyModel.
Before adding the proxyModel the model+view worked as intended.
However since I've added the filter there is the problem, that somehow the columnCount() is not updated correctly in the proxyModel.When inserting a column via beginInsertColums() / endInsertColums() (which is done in the sourceModel) the columnCount() of the sourceModel itself shows the correct value.
However the columnCount() of the QSortFilterProxyModel still shows the old value.
Do I need to implement any additional functions (except for filterAcceptsRow()) for that to work, or is there something wrong with my model? -
Sounds like a bug in Qt to me.
To force an update, you can call
invalidate()on your proxy model, it will trigger a refresh. -
Thanks for the hint with invalidate().
That somehow solves the problem, however only when I trigger it separately from a button or it is called with delay viaQTimer::singleShot(2, m_tree_filter, SLOT(invalidate()));This somehow seems to be a unclean solution though. Any ideas why this could happen.
Qt5.15.2 / Debian
-
Thanks for the hint with invalidate().
That somehow solves the problem, however only when I trigger it separately from a button or it is called with delay viaQTimer::singleShot(2, m_tree_filter, SLOT(invalidate()));This somehow seems to be a unclean solution though. Any ideas why this could happen.
Qt5.15.2 / Debian
@gde23 said in QSortFilterProxyModel: problem with columnCount():
Qt5.15.2 / Debian
Using outdated Qt is always a good culprit. Try with 6.4.1 or 5.15.11.
-
I'm pretty sure QSFPM is correct and you're doing something wrong. Please provide a minimal, compilable example of your issue.