Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

seems like delegate.index doesn't work well



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

  • Qt Champions 2017

    How many elements in the model ? Can you show us the view & your model as well ?


Log in to reply