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



  • 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.



  • 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.



  • 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


Log in to reply
 

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