Important: Please read the Qt Code of Conduct -

How to filter first row of the model

  • I have written model in Qt and i am using QML list view to display the model content. I want to filter zeroth row of the model that means i want to display the content from index 1 to index n. Let me know how can we do it

  • Qt Champions 2018

    Two solution for that :
    You could hide the first row in your delegate, with something like visible: model.index !== 0.
    Or you could really filter it with a proxy model.

    I've written a library to accomplish this :

    You could use it this way :

    import SortFilterProxyModel 0.2
    // ...
    SortFilterProxyModel {
        id: proxyModel
        sourceModel: myModel
        filters: IndexFilter { minimumIndex: 1 } // show elements from index 1 and up
    ListView {
        model: proxyModel
        // ...

Log in to reply