Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

QTreeView with QSortFilterProxyModel extremly slow with many (~5000) items



  • Hello,

    I have a QTreeView that displays some date which is in a class derived from QAbstractItemModel.
    When displaying many items (without filter) the view was slow.
    Therefore I added

        setUniformRowHeights(true);
    

    and now it is running without unusual delay.

    However I need to filter the Items in the view.
    Therfore I've added a QSortFilterProxyModel.
    However this leads to an extremly slow view (even when filterAcceptsRow() does nothing and just returns true).

    Is there some known issue with the QSortFilterProxyModel on large (~5000 items, which is not extemly large) data, or any tricks how I can speed it up?


  • Lifetime Qt Champion

    What Os, What Qt version, minimal example please.



  • @Christian-Ehrlicher
    OS: Debian 10
    QtVersion: 5.13.0

    I've just tried to generate some minimal example from the editable-treemodel example in the Qt-Examples folder, however it runs perfectly fast there also with the filter.

    So it seems the problem is somewhere else.

    Ok, I found the problem.
    Thanks for demanding a minimal example :)

    The reason was, that my columnCount() function is iterative and asking all children for their columnCount to find the max columnCount needed for the view. I will change this to some lazy evaluation then everything should be fine


  • Lifetime Qt Champion

    @gde23 said in QTreeView with QSortFilterProxyModel extremly slow with many (~5000) items:

    Thanks for demanding a minimal example :)

    Thx for trying to create one - sadly a lot of people don't understand the demand for this but this here is a good example why it's needed :)