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.onRemove animation not running when using QStandardItemModel
Qt 6.11 is out! See what's new in the release blog

Listview.onRemove animation not running when using QStandardItemModel

Scheduled Pinned Locked Moved QML and Qt Quick
3 Posts 1 Posters 3.1k 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.
  • M Offline
    M Offline
    markg85
    wrote on last edited by
    #1

    Hi,

    In my project i have sub-classed QStandardItemModel and added some data to it. So far everything works well.
    However, when removing an item i want to show a nice animation and that is where the issues start to appear.

    I tried using the ListView.delayRemove "trick" as described here: http://doc.qt.nokia.com/4.7/qml-listview.html but it didn't help. As soon as i click remove the item simply gets instantly removed.
    This is how i made it available in QML though C++:

    -- header --
    @ Q_INVOKABLE void removeRow( const double & row );@

    -- cpp --
    @void TodoItemModel::removeRow(const double &row)
    {
    QStandardItemModel::removeRow(row);
    }@

    And this is how i call it in QML:
    @todoModelData.removeRow(index);@

    todoModelData is the model. It does actually remove the data so the remove itself works fine, but i somehow want to have that delay mechanism working to show a nice animation. When i simply use a ListMode it works as intended, but ListModel is to limited for my needs besides that i need to fill my model from C++.

    I tried asking on IRC, but despite a couple dozen people are "online" in #qt-qml, it's non responsive.

    I hope anyone in here is able to help me with this pesky issue.

    Kind regards,
    Mark

    1 Reply Last reply
    0
    • M Offline
      M Offline
      markg85
      wrote on last edited by
      #2

      I found a way to fix it although that is with bypassing ListView.onDelete ... What i did is make a custom animation as follows:
      @ SequentialAnimation
      {
      id: animateTodoRowOut
      running: false
      ParallelAnimation
      {
      NumberAnimation
      {
      target: todoRow
      properties: "opacity"
      to: 0.0
      duration: 100
      }
      NumberAnimation
      {
      target: todoRow
      properties: "scale"
      to: 2.0
      duration: 300
      }
      }
      ScriptAction { script: todoModelData.removeRow(index); }
      }@

      And that gets called when i press my delete button. It works exactly the same as it would when onDelete had worked and is probably a nice bypass method.. But i really don't want to bypass anything and just use onDelete! If anyone has any suggestions for me to use that?

      1 Reply Last reply
      0
      • M Offline
        M Offline
        markg85
        wrote on last edited by
        #3

        bump.. any help would be welcome

        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