MouseArea inside SplitView item takes mouse events away from Splitview handle

337 views Asked by At

I am using qt quick controls 2 SplitView and it seems like any MouseArea inside the SplitView's item takes mouse events away from the SplitView handle. This means that dragging the handle is not possible when the handle is over a component that has a MouseArea, e.g. Button, inside the SplitView's item.

import QtQuick 2.12
import QtQuick.Window 2.12
import QtQuick.Controls 2.13

Window {
    width: 640
    height: 480
    visible: true
    title: qsTr("Hello World")

    SplitView {
        id: splitView
        anchors.fill: parent
        handle: Rectangle {
            id: handle
            implicitWidth: 20
            color: "red"
        }

        Page {
            id: firstPage
            Button {
                id: button
                implicitWidth: 100
                implicitHeight: 50
                text: "button"
            }
        }

        Page {
            id: secondPage
        }
    }
}

Normal behaviour:

working gif

Button blocks mouse events from handle:

not working gif

I tried setting the z value of splitView and handle greater than the z value of firstPage and button but that didn't work.

2

There are 2 answers

0
jianpeng xu On BEST ANSWER
   Page {
        id: firstPage
        clip: true
        Button {
            id: button
            implicitWidth: 100
            implicitHeight: 50
            text: "button"
        }
    }

You have to active clip on page. I tested on a empty projet it work.:D I suppose the right side of loaded button under handle bar is still active. (if someone know precisely why leave a comment)

1
Ben Mishali On

Try to set the z value of first page and second page to -1 and SplitView to 1