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. seems like delegate.index doesn't work well
Qt 6.11 is out! See what's new in the release blog

seems like delegate.index doesn't work well

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
2 Posts 2 Posters 218 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.
  • W Offline
    W Offline
    wym94
    wrote on last edited by
    #1

    when I clicked item, I got a -1 index? can anybody told me what happened?

    output:

    qml: view.currnetIndex:-1
    qml: index:-1
    qml: mainRect.currentIndex:0

    delegate:

    Rectangle {
        height: 102
        width: parent.width
        color: "transparent"
        MouseArea {
            anchors.fill: parent;
            onClicked: {
                console.log('view.currnetIndex:'+view.currentIndex)
                console.log('index:'+index)
                console.log('mainRect.currentIndex:'+mainRect.currentIndex)
    
                if (view.currentIndex == index)
                    mainRect.currentIndex = 1;
                else
                    view.currentIndex = index;
            }
        }...
    
    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 many elements in the model ? Can you show us the view & your model as well ?

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

      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