Listview.onRemove animation not running when using QStandardItemModel

  • 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: 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)

    And this is how i call it in QML:

    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,

  • 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
    target: todoRow
    properties: "opacity"
    to: 0.0
    duration: 100
    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?

  • bump.. any help would be welcome

Log in to reply

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.