[Interest] Strange mouse move event handling

Данил Патрушев dannix84 at gmail.com
Wed Oct 26 17:53:48 CEST 2016


Hi, everyone. I stumbled across behavior which looks as a bug to me. Qt 5.7

import QtQuick 2.2

import QtQuick.Controls 1.1


ApplicationWindow {

    visible: true

    width: 2048/2

    height: 1536/2

    Rectangle {

        id: big

        x: 10

        y: 20

        width: 400

        height: 400

        MouseArea {

            anchors.fill: parent

            drag.target: parent

            drag.filterChildren: true


            Rectangle {

                id: green

                x: 30; y: 30

                width: 100; height: 100

                color: "green"



                MouseArea {

                    anchors.fill: parent

                }

            }


            Rectangle {

                id: red

                x: 200; y: 30

                width: 100; height: 100

                color: "red"



                MouseArea {

                    anchors.fill: parent

                    onPressed: mouse.accepted = false

                }

            }


        }

    }

}



Basically, there's a large rectangle containing two small rectangles. Each
of them contains a mouse area, the big rectangle's mouse area is supposed
to make the big rectangle draggable, so drag.filterChildren is set to true
to intercept drags.  The green rectangle's mouse area accepts mouse press
events, the red rectangle's mouse area is specifically told not to. The
result: I can drag the big rectangle by dragging the green rectangle, but I
can't do the same by dragging the red one. By looking at the source code I
concluded that the filtering mechanism relies on the fact that some item on
top of the mouse area receiving filtered events  actually accepts press
events. This does not seem right to me, I want the big rectangle to be
dragged no matter how items on top handle mouse press events, what do you
think?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20161026/0518bef1/attachment.html>


More information about the Interest mailing list