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. How can I access the "currentItem" of a ListView before it is changed by selecting a new item?
Forum Updated to NodeBB v4.3 + New Features

How can I access the "currentItem" of a ListView before it is changed by selecting a new item?

Scheduled Pinned Locked Moved QML and Qt Quick
3 Posts 2 Posters 949 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
    Duff
    wrote on last edited by
    #1

    So I have some animations happening on my ListView items in the case that they are too long for their container. When the user hits an up or down arrow key I can set these animations in motion (if necessary) on the next item the user is selecting using the "onCurrentItemChanged" property/event. Problem is if the current Item is being animated then I need to stop that animation before moving onto the item in the list. Any idea how to do that? I can't find an event that allows me to trap the currentItem and make changes before the current item is changed to the next item.

    --Duff

    1 Reply Last reply
    0
    • J Offline
      J Offline
      Jens
      wrote on last edited by
      #2

      I don't believe there is a simple way to block the currentItem value from changing instantly unless you handle your own key events. But did you consider just creating a property "previousItem" and updating that after in onCurrentItemChanged? Then you will still have a handle to the previous item so you can roll back that animation.

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

        I actually did get it to work by handling the up and down key events. Problem is that if you handle the key event then that bypasses the normal behavior of list navigation by the keys so you have to call the incrementCurrentIndex or decrementCurrentIndex when your done. It works, but I think I like your idea a little better. Thanks!

        Brian

        --Duff

        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