[Development] Nested Mousearea don't pass events
Sean Harmer
sean.harmer at kdab.com
Sat Jun 1 19:08:17 CEST 2013
On 20/05/2013 13:36, Matteo Brichese wrote:
> Hi everyone, I'm having some issue on passing the right event from a mousearea to another.
>
> This is a sample of my code:
>
> import QtQuick 2.0
>
> Rectangle {
> width: 1024
> height: 768
>
> MouseArea {
> anchors.fill: parent;
> onClicked: console.log("Click")
> }
>
> MouseArea {
> anchors.fill: parent;
> onDoubleClicked: console.log("Double Click")
> }
> }
>
> I can only see logs of the double click.
> I was hoping that if I single click the last mousearea the event passed to the second one, but it don't work, is that a bug?
>
> I'm using Qt5.0.2
You need to set
propagateComposedEvents: true
on the top MouseArea and in the signal handler of the top MouseArea set
mouse.accepted = false
so that it propagates clicks, doubleClicks etc to the underlying
MouseArea. See
http://doc-snapshot.qt-project.org/qt5-release/qtquick/qml-qtquick2-mousearea.html#propagateComposedEvents-prop
Cheers,
Sean
--
Dr Sean Harmer | sean.harmer at kdab.com | Senior Software Engineer
Klarälvdalens Datakonsult AB, a KDAB Group company
Tel. Sweden (HQ) +46-563-540090, USA +1-866-777-KDAB(5322)
KDAB - Qt Experts - Platform-independent software solutions
More information about the Development
mailing list