Qt 带鼠标的TreeView委托ea:传播鼠标
我有一个带有自定义委托的Qt 带鼠标的TreeView委托ea:传播鼠标,qt,qml,Qt,Qml,我有一个带有自定义委托的TreeView。代理使用工具提示,如果将代理mouseArea悬停,将显示该提示。但是,此鼠标会中断在my树视图中选择行的过程。我假设点击不会传播到TreeView的mouseArea。我尝试了propagateComposedEvents和mouse.accepted=false但选择仍然无效 TreeView { id: view anchors.fill: parent sortIndicatorVisible: true mode
TreeView
。代理使用工具提示
,如果将代理mouseArea
悬停,将显示该提示。但是,此鼠标会中断在my树视图中选择行的过程。我假设点击不会传播到TreeView
的mouseArea。我尝试了propagateComposedEvents
和mouse.accepted=false
但选择仍然无效
TreeView {
id: view
anchors.fill: parent
sortIndicatorVisible: true
model: fileSystemModel
rootIndex: rootPathIndex
selection: sel
selectionMode: 2
Component {
id: mycomp
Item {
id: myitm
Row{
id: myrow
CheckBox{
id: cbox
anchors.baseline: ctext.baseline
}
Text{
id: ctext
text: styleData.value
color: styleData.textColor
width: namecolumn.width-cbox.width-myrow.x
elide: Text.ElideRight
}
}
NC.ToolTip {
id: ttip
parent: ctext
text: qsTr(styleData.value)
delay: 500
visible: mouseArea.containsMouse
}
MouseArea {
id: mouseArea
anchors.fill: parent
hoverEnabled: true
propagateComposedEvents: true
onClicked: {
mouse.accepted = false
}
}
}
}
只需将MouseArea的acceptedButtons属性设置为Qt.NoButton。此属性决定了该区域将处理的按钮。NoButton会导致该区域报告悬停事件,但不会处理任何单击
请参阅此处有关该属性的完整文档: