Qt Forum

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

    Update: Forum Guidelines & Code of Conduct

    Virtual Sort never gets called on QAbstractListModel derived class

    General and Desktop
    2
    7
    3447
    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.
    • R
      ronM71 last edited by

      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 Reply Quote 0
      • G
        giesbert last edited by

        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 Reply Quote 0
        • R
          ronM71 last edited by

          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 Reply Quote 0
          • R
            ronM71 last edited by

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

            1 Reply Last reply Reply Quote 0
            • G
              giesbert last edited by

              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 Reply Quote 0
              • R
                ronM71 last edited by

                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 Reply Quote 0
                • G
                  giesbert last edited by

                  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 Reply Quote 0
                  • First post
                    Last post