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. Reorder Row items in ListView with SortFilterProxyModel
Forum Updated to NodeBB v4.3 + New Features

Reorder Row items in ListView with SortFilterProxyModel

Scheduled Pinned Locked Moved Solved QML and Qt Quick
2 Posts 2 Posters 265 Views 1 Watching
  • 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.
  • K Offline
    K Offline
    KaNe09
    wrote on 7 Oct 2020, 12:14 last edited by
    #1

    I want to create a movement of items in a ListView as you can see at:
    https://doc.qt.io/qt-5/qml-qtquick-viewtransition.html under Restrictions Regarding ScriptAction

    I have:

    ListView {
    ...
    model: SortFilterProxyModel
    populate: Transition {
      NumberAnimation {
               properties: "y"
               duration: 1000
      }
    }
    ...
    delegate: Row {
    ...
    Text {
          text: SortFilterProxyModel.name
    }
    Text {
          text: SortFilterProxyModel.prename
    }
    }
    

    I can't use SortFilterProxyModel.move() because this method does not exist. My SortFilterProxyModel is sorted by the method SortProxyModel::sort() in my C++-Code.
    How can I animate the reorder of the row items in my view? The populate - transistion moves all rows from the top of the ListView to each position of the item. But I want the simulation of the above url. For example: second row of ListView moves to row 8 and the rows 1, 3-7 moves one row upwards and the rows 8-10 moves one row downwards.
    How can I get this?

    1 Reply Last reply
    0
    • G Offline
      G Offline
      GrecKo
      Qt Champions 2018
      wrote on 8 Oct 2020, 09:07 last edited by
      #2

      I guess your SortFilterProxyModel is a subclass of QSortFilterProxyModel, this class doesn't really behave well regarding rows being moved around.

      If the source model move its row, it will emit a layoutChanged signal. Same thing if the rows need to be moved due to their data being changed and the sorting thus being affected.

      This means that the move or moveDisplaced transitions in a ListView using a QSortFilterProxyModel will never be called.
      An alternative could be using SortProxyModel from KDtoolBox by KDAB

      1 Reply Last reply
      1

      1/2

      7 Oct 2020, 12:14

      • Login

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