Qt Forum

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

    Unsolved Listview viewing order

    QML and Qt Quick
    listview vieworder
    3
    7
    659
    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.
    • T
      ThMars last edited by

      I have a listview in which I can change the order by dragging an item (QML Dynamic View Ordering Tutorial 1 - A Simple ListView and Delegate)
      My question now is "how can I read back the viewing order after manually sorting the view"

      raven-worx 1 Reply Last reply Reply Quote 0
      • raven-worx
        raven-worx Moderators @ThMars last edited by

        @ThMars
        Since the model is in a separate file/component, create another instance of it, which of course will have the initial order

        --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
        If you have a question please use the forum so others can benefit from the solution in the future

        1 Reply Last reply Reply Quote 0
        • T
          ThMars last edited by ThMars

          I do not want the original order to save but read / get from the listview the order that is established after the items have been dragged to their new positions in the view. My model is derived from an array and I have to change the order of the array conform the view.

          raven-worx 1 Reply Last reply Reply Quote 0
          • raven-worx
            raven-worx Moderators @ThMars last edited by

            @ThMars
            k, my fault.
            Oddly I think there is no convenient way. A Workaround could be to make the index part of the model data (in the ListModel), then access it this way:
            The example uses a proxy model (DelegateModel), which provides a items property of the DelegateModelGroup, which provides a get() method.
            And returns a JS object with a object with certain properties:
            https://doc.qt.io/qt-5/qml-qtqml-models-delegatemodelgroup.html#get-method

            --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
            If you have a question please use the forum so others can benefit from the solution in the future

            1 Reply Last reply Reply Quote 0
            • T
              ThMars last edited by

              Ok but then again that wil be the original index and that is not what I want, I will try to make use of the index when the items are moved (listmodel.move(from, int to, int n)). Like you said probably not a simple way.

              raven-worx 1 Reply Last reply Reply Quote 0
              • raven-worx
                raven-worx Moderators @ThMars last edited by

                @ThMars
                then check the itemsIndex property of the returned object

                --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
                If you have a question please use the forum so others can benefit from the solution in the future

                1 Reply Last reply Reply Quote 0
                • W
                  Wip-Sama last edited by

                  Thi is quite late but did you find a solution? I've the same problem and could not find a way till now...

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