Qt Forum

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

    Update: Forum Guidelines & Code of Conduct

    Help needed in Qtreeview sorting

    General and Desktop
    2
    4
    1107
    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.
    • S
      sathishm last edited by

      Hi,
      I am working on a Qt UI application. I use a qtreeview to display the contents in the UI. I have enabled sorting by using setsortingEnabled(true) function. In my application i have a Qlist that also holds the contents of qtreeview (and few more details). The problem i am facing is when i click on the Qtreeview header only the qtreeview is sorted and the Qlist is unchanged. I want this Qlist to be sorted also. I was searching the the internet to see of there is a signal emitted during sort so that i can manually sort the qlist but couldnot find one.
      Please tell me if any signal is emitted during the sorting of qtreeview that i can use. also let me know if there is some other idea that i can explore on this.

      Thanks,
      Sathish

      1 Reply Last reply Reply Quote 0
      • SGaist
        SGaist Lifetime Qt Champion last edited by

        Hi,

        I'm not sure I'm understanding correctly. Do you want to modify your underlying data when sorting your QTreeView ?

        Interested in AI ? www.idiap.ch
        Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

        1 Reply Last reply Reply Quote 0
        • S
          sathishm last edited by

          Hi,
          I have a "copy of" the treeview contents stored in a Qlist. when qtreeview is sorted, i want to sort the Qlist as well.
          each row in the treeview corresponds to a node in the Qlist,i am maintaining.
          each qlist node has more details of the row needed for backend processing. So when i click on the Qtreeview header for sorting, Is there any signal emitted that i can you to manually sort the Qlist?.
          Please let me know if you need more information.

          1 Reply Last reply Reply Quote 0
          • SGaist
            SGaist Lifetime Qt Champion last edited by

            AFAIK, no there's not. You'll have to do it by hand. But still, I don't see why you need do such a double sorting. Sorting the view and the internal data just doubles the work and if you have other views on the same model then they will also get influenced by that.

            Interested in AI ? www.idiap.ch
            Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

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