首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >TreeView代表与MouseArea:传播鼠标

TreeView代表与MouseArea:传播鼠标
EN

Stack Overflow用户
提问于 2018-04-30 15:18:27
回答 1查看 494关注 0票数 0

我有一个带有自定义委托的TreeView。委托使用ToolTip,如果挂起委托mouseArea,则会显示该mouseArea。但是,这个mouseArea不能在我的TreeView中选择一行。我认为单击不会传播到TreeView的mouseArea。我尝试了propagateComposedEventsmouse.accepted=false,但是选择仍然不起作用。

代码语言:javascript
复制
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
                }

            }
        }

    }
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2018-04-30 15:23:26

只需将MouseArea的MouseArea属性设置为Qt.NoButton即可。此属性确定该区域将处理的按钮。NoButton会使该区域报告悬停事件,但不会处理任何单击。

请参阅此处有关该属性的完整文档:

http://doc.qt.io/qt-5/qml-qtquick-mousearea.html#acceptedButtons-prop

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/50103461

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档