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. Virtual Sort never gets called on QAbstractListModel derived class
QtWS25 Last Chance

Virtual Sort never gets called on QAbstractListModel derived class

Scheduled Pinned Locked Moved General and Desktop
7 Posts 2 Posters 3.8k 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.
  • R Offline
    R Offline
    ronM71
    wrote on last edited by
    #1

    defined

    @virtual void sort (int column, Qt::SortOrder order = Qt::AscendingOrder);@

    It's never called on my model although the model is used correctly, and provides the content for the QListView it's attached to.

    Any ideas why?

    1 Reply Last reply
    0
    • G Offline
      G Offline
      giesbert
      wrote on last edited by
      #2

      It depends, how it (the view) is used

      is the view that displays the model, sorted?

      is there a QSFPM (QSortFilterProxyModel) in between?

      do you call it directly?

      Nokia Certified Qt Specialist.
      Programming Is Like Sex: One mistake and you have to support it for the rest of your life. (Michael Sinz)

      1 Reply Last reply
      0
      • R Offline
        R Offline
        ronM71
        wrote on last edited by
        #3

        There is no QSortFilterProxyModel. I am using QListView, QAbstractListModel and QAbstractItemDelegate.

        How can the view be sorted? QListView (and its parent classes) doesn't have any sorting. Is there a method I am missing?

        Ideally I don't want to call it directly. I want it to be sorted whenever i make changes like adding items to it. etc.

        1 Reply Last reply
        0
        • R Offline
          R Offline
          ronM71
          wrote on last edited by
          #4

          Should I be using a different set of view/model classes if I want automatic sort?

          1 Reply Last reply
          0
          • G Offline
            G Offline
            giesbert
            wrote on last edited by
            #5

            By default, a list view is not sorted, so why should it be called if you don't call it? Sort is something that can be used, but if you don't call it, the list v9iew does not!

            In a list view, you have to call sort by hand.

            A table view has a sorting property, as it can sort by different columns.

            Nokia Certified Qt Specialist.
            Programming Is Like Sex: One mistake and you have to support it for the rest of your life. (Michael Sinz)

            1 Reply Last reply
            0
            • R Offline
              R Offline
              ronM71
              wrote on last edited by
              #6

              Understood. I can definitely do it manually, Just wanted to know if there was a mechanism by which it'll be called automatically. Thanks for your help.

              1 Reply Last reply
              0
              • G Offline
                G Offline
                giesbert
                wrote on last edited by
                #7

                On a table with sortingenabled it would be called automatically, but not on a list view.

                Nokia Certified Qt Specialist.
                Programming Is Like Sex: One mistake and you have to support it for the rest of your life. (Michael Sinz)

                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