Qt World Summit: Register Today!

[SOLVED] PathView: accessing delegate at current index

  • I have PathView filled with the list of delegates. How do I access a delegate at current index?

  • Question is: why would you need to? Sounds like you are trying to do something imperative, when you should be doing something declarative instead... But, I could very well be wrong, of course.

  • I have a carousel view implemented with PathView. Here is the example it is based on:

    The thing is that I need to make one of the items special by sending an event from outside of the PathView. I have a button which suppose to make a current item special when pressed. PathView provides me with the curentIndex, but it seems there is no way to access the current item itself. Or is there?

  • Should be easy to solve. Every delegate has access to it's index, and can access any other non-dynamic item in the scene by id. So, why don't you just put the index number that works as the "special" index as a property in an index somewhere, and let the delegates determine based on that if they are The Chosen One? Or, alternatively, you might simply make it a property of the model itself.

  • Thanks for the idea! It works now. Solved by adding additional property to the listModel, and then modifying it according to the current index of PathView:

    @onClicked: listModel.setProperty(pathview.currentIndex, "active", true)@

Log in to reply