Qt World Summit: Register Today!

[SOLVED] Is it possible to define an action for the removal of an item in a ListView?

  • So I have a ListView with a few dynamically created items. Some of the items have started a timer. At some point, the list gets refreshed and all references to the timers are gone.
    Conclusion: Stop the timers before the item is removed from the list (with ListModel.clear()). Is it somehow possible to do this? I look for something like onVisibleChanged {do some fancy stuff when the visible property changed }. Or do you know any others solutions?

    Thanks in advance :-)

  • Qt Champions 2017

    how about catching onRemove signal ? This will help you.

  • Yap, that is something I was thinking about, but there is no onRemove for Component or Item (The types my delegate for the list consists of and where the reference to the timer is held).

    Where can I catch onRemove?


    Ok, figured it out. Had to use

    @ ListView.onRemove: {
    On the first Item in the delegate (not one of the children) and it worked. Still strange that the QtCreator code completion doesnt "know" about the onRemove signal from ListView.

Log in to reply