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
Forum Updated to NodeBB v4.3 + New Features

seems like delegate.index doesn't work well

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
2 Posts 2 Posters 195 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
      Qt Champions 2022
      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
      http://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