0
votes

I have a TreeView with a custom delegate. The delegate uses a ToolTip, which will be shown if the delegates mouseArea is hovered. However, this mouseArea breaks selecting a row in my TreeView. I suppose that a click is not propagated to the TreeView's mouseArea. I tried propagateComposedEvents and mouse.accepted=false but selection does still not work.

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
                }

            }
        }

    }
1

1 Answers

1
votes

Just set the acceptedButtons property of the MouseArea to Qt.NoButton. This property determined the buttons the area will handle. NoButton causes the area to report hover events but it will not handle any clicks.

See the full documentation for the property here:

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