如何在 TreeView 中获取 delegateItem 的 currentIndex

How to get currentIndex of an delegateItem in a TreeView

你好,

当在 Column 上使用 delegate 时,如果用户点击 delegateItem,我如何知道选择的 CellRow 的索引] ?

这是一个例子。第二个 ColumnMouseArea,当用户点击 MouseArea:

时,我想 expand currentIndex
TreeView {
    id: view
    TableViewColumn {
        title: "Name"
        role: "fileName"
        width: 300
    }
    TableViewColumn {
        title: "Permissions"
        role: "filePermissions"
        width: 100
        delegate : MouseArea {
            id:mous
            onClicked {
                 //get indexMouseArea
                 view.expand(indexMouseArea)
            }
        }
    }
    model: fileSystemModel

    onExpanded {
       console.log("expanded :" + index)
    }
}

解决方法感谢@mcchu:

你好,

在列上使用委托时,如果用户单击委托项,我如何知道所选单元格或行的索引?

这是一个例子。第二列是 MouseArea,我想在用户单击 MouseArea 时展开 currentIndex:

TreeView {
    id: view
    TableViewColumn {
        title: "Name"
        role: "fileName"
        width: 300
    }
    TableViewColumn {
        title: "Permissions"
        role: "filePermissions"
        width: 100
        delegate : MouseArea {
            id:mous
            onClicked {
                view.expand(styleData.index);
            }
        }
    }
    model: fileSystemModel

    onExpanded {
       console.log("expanded :" + index)
    }
}