Search code examples
sortingqmltableviewqtquickcontrols

QML sorting in tableview is very slowly


I use QML TableView + own QAbstractTableModel and QSortFilterProxyModel. I've implemented sorting, but it works slowly. I've used these models without QML, but with QTableView - it worked perfectly. 30 000 items sort less then 1 secs. Can anybody help? Where problem is?


Solution

  • I've supposed that QML repaint all items while Model is sorting data (in every iteration). I've found solution, for sorting you have to:

    1. Turn off model in QML
    2. Sorting items (use model)
    3. Return back model.

    For example

    onSortIndicatorOrderChanged: {
        model = null
        MyModel.Sort(...)
        model = MyModel
    }
    

    More details https://forum.qt.io/topic/52026/solved-sorting-qml-tableview-is-slow/4