Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. How to make a user defined Model able to be sorted?

How to make a user defined Model able to be sorted?

Scheduled Pinned Locked Moved Solved General and Desktop
5 Posts 2 Posters 366 Views
  • 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.
  • J Offline
    J Offline
    jdent
    wrote on last edited by
    #1

    I have a Model inheriting from QAbstractTableModel and it implements

    rowCount
    columnCount
    data
    

    but I cannot make it sort by column. I am using QTableView with setSortingEnabled set to true!

    What am I missing? How can I make my model sortable?

    1 Reply Last reply
    0
    • JonBJ Online
      JonBJ Online
      JonB
      wrote on last edited by
      #2

      Usually you would interpose a QSortFilterProxyModel

      1 Reply Last reply
      1
      • J Offline
        J Offline
        jdent
        wrote on last edited by
        #3

        what do you mean to interpose?

        1 Reply Last reply
        0
        • J Offline
          J Offline
          jdent
          wrote on last edited by
          #4

          I got it!
          Thanks

          JonBJ 1 Reply Last reply
          0
          • J jdent has marked this topic as solved on
          • J jdent

            I got it!
            Thanks

            JonBJ Online
            JonBJ Online
            JonB
            wrote on last edited by JonB
            #5

            @jdent
            :) "Interpose" the proxy model between the source model and the view. The QSFPM makes it easy to manage sorting, and you get filtering too for free if you want it. Use this if you want either sorting or filtering (or both).

            1 Reply Last reply
            0

            • Login

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • Users
            • Groups
            • Search
            • Get Qt Extensions
            • Unsolved