qml:Treeview 鼠标右键响应

tech2024-08-16  42

qml TreeView只响应鼠标左键的按键事件,可通过MouseArea捕捉鼠标右键动作,进行响应

TreeView { id: view MouseArea{ anchors.fill: parent acceptedButtons: Qt.RightButton onClicked: { console.log("onClicked right", view.indexAt(mouseX, mouseY)) //直接用view.currentIndex = view.indexAt(mouseX, mouseY)会报错提示currentIndex为只读属性 view.__listView.currentIndex = view.__listView.indexAt(mouseX, mouseY) } } }
最新回复(0)