[Interest] How to handle click events in Flickable as well as MouseArea the same time (QML)

Roopesh Chander roop at forwardbias.in
Tue Jul 3 13:34:26 CEST 2012

I've spent quite some time fighting with this problem. :)

The trick, as I found out, is to have the MouseArea as a child of the
Flickable (as opposed to a MouseArea with a higher z value). If we do
that, then when the Flickable thinks that it has a flick, it can
"steal" the mouse events for itself and doesn't deliver it at all to
the MouseArea. If it thinks it's not a flick, it passes on the event
to it's children. (This is how ListItems getting clicked works.)

This is also mentioned in the docs, though somewhat hidden:


On Tue, Jul 3, 2012 at 2:11 PM, Daniel Kreuter
<daniel.kreuter85 at googlemail.com> wrote:
> Hello,
> I have a small pdf viewer in qml which enables scrolling using the
> Flickable component. Now I want the navigation controls to switch
> between the pages to switch it's opacity to 0 after a few seconds so
> they won't be in the readers way. The only way to get them back
> visible would be to have a MouseArea which will set opacity back to 1
> and restart it's animation for fade out. Mouse hover will not work
> because this viewer will only be used via touch events.
> Now the problem is, that when I define the MouseArea which lays over
> the Flickable catches each clicked() signal, so I won't be able to
> scroll anymore. So how can I reemit the signal clicked to be caught by
> the Flickable as well? Is this possible?
> --
> Mit freundlichen Grüßen
> Greetings
> Daniel Kreuter
> _______________________________________________
> Interest mailing list
> Interest at qt-project.org
> http://lists.qt-project.org/mailman/listinfo/interest

More information about the Interest mailing list