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] PathView: accessing delegate at current index
QtWS25 Last Chance

[SOLVED] PathView: accessing delegate at current index

Scheduled Pinned Locked Moved QML and Qt Quick
5 Posts 2 Posters 2.8k Views
  • 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.
  • S Offline
    S Offline
    strekazoid
    wrote on last edited by
    #1

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

    1 Reply Last reply
    0
    • A Offline
      A Offline
      andre
      wrote on last edited by
      #2

      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.

      1 Reply Last reply
      0
      • S Offline
        S Offline
        strekazoid
        wrote on last edited by
        #3

        I have a carousel view implemented with PathView. Here is the example it is based on:
        http://developer.qt.nokia.com/wiki/Qt_Quick_Carousel

        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?

        1 Reply Last reply
        0
        • A Offline
          A Offline
          andre
          wrote on last edited by
          #4

          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.

          1 Reply Last reply
          0
          • S Offline
            S Offline
            strekazoid
            wrote on last edited by
            #5

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

            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