Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. Listview viewing order
QtWS25 Last Chance

Listview viewing order

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
listviewvieworder
7 Posts 3 Posters 1.5k 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.
  • T Offline
    T Offline
    ThMars
    wrote on last edited by
    #1

    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-worxR 1 Reply Last reply
    0
    • T ThMars

      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-worxR Offline
      raven-worxR Offline
      raven-worx
      Moderators
      wrote on last edited by
      #2

      @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
      0
      • T Offline
        T Offline
        ThMars
        wrote on last edited by ThMars
        #3

        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-worxR 1 Reply Last reply
        0
        • T 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-worxR Offline
          raven-worxR Offline
          raven-worx
          Moderators
          wrote on last edited by
          #4

          @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
          0
          • T Offline
            T Offline
            ThMars
            wrote on last edited by
            #5

            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-worxR 1 Reply Last reply
            0
            • T ThMars

              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-worxR Offline
              raven-worxR Offline
              raven-worx
              Moderators
              wrote on last edited by
              #6

              @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
              0
              • W Offline
                W Offline
                Wip-Sama
                wrote on last edited by
                #7

                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
                0

                • Login

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