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. [SOLVED] Is it possible to define an action for the removal of an item in a ListView?
Qt 6.11 is out! See what's new in the release blog

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

Scheduled Pinned Locked Moved QML and Qt Quick
3 Posts 2 Posters 730 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.
  • D Offline
    D Offline
    DerMas
    wrote on last edited by
    #1

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

    1 Reply Last reply
    0
    • dheerendraD Offline
      dheerendraD Offline
      dheerendra
      Moderators Qt Champions 2024 Qt Champions 2022 Qt Champions 2017
      wrote on last edited by
      #2

      how about catching onRemove signal ? This will help you.

      Dheerendra
      @Community Service
      Certified Qt Specialist
      https://www.pthinks.com

      1 Reply Last reply
      0
      • D Offline
        D Offline
        DerMas
        wrote on last edited by
        #3

        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?

        edit:

        Ok, figured it out. Had to use

        @ ListView.onRemove: {
        console.log("Remove")
        }@
        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.

        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