Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Solved Can I turn sorting on or off in QSortFilterProxyModel?

    General and Desktop
    2
    2
    277
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • P
      Pada_ last edited by

      Can I turn sorting on or off in QSortFilterProxyModel?

      I want to sort the first second column when it is clicked, and sort off when the column is pressed.

      JonB 1 Reply Last reply Reply Quote 0
      • JonB
        JonB @Pada_ last edited by

        @Pada_
        There are several possible ways to achieve this. If you have derived your own class, your can override http://doc.qt.io/qt-5/qsortfilterproxymodel.html#sort to decide to do nothing if the column is not one you want to sort on. Or, you could do the work at the view side instead of in the model if you prefer.

        1 Reply Last reply Reply Quote 0
        • First post
          Last post