[Qt-interest] QTouchEvent/QGestureEvent propagation

Sean Hayes sean.t.hayes at vanderbilt.edu
Mon Apr 11 17:48:07 CEST 2011


On Mon, Apr 11, 2011 at 10:09 AM, Stephen M. Webb <
stephen.webb at bregmasoft.ca> wrote:

> On Sun, 2011-04-10 at 22:33 +0200, Wathek LOUED wrote:
> > Hi all,
> >
> > I've noticed that the Events in Qt using the
> > QGraphicsView/QGraphicsScene/QGraphicsItem are spread from the
> QGraphicsView
> > then to the QGraphicsScene and the to the item that got the lowest
> Z-Index
> > to the most top item.
> >
> > I think that that's a bit weird cause generally when using QTouchEvent
> and
> > QGesture we look at the most top element so imagine that you programmed a
> > gesture and that that gesture occured at position (x, y) and in that
> > position there's 4 items that are grabbing the same gesture, so it'll be
> > grabbed by all the item and not the top element won't it ?
>
> But imagine the scenario in which a multi-touch gesture is made with
> four fingers spread across the scene?  Which element should receive the
> event?  Should all elements receive a single-finger gesture or does a
> 4-finger gesture have some significance?  Is the QGraphicsScene not the
> right place to determine that?


I would argue that to proper place is dependent on your design. If you have
two separate gesture types (one for single finger gestures and one for
4-finger gestures), then the scene could grab 4-fingered gestures and
QGraphicsObjects could grab the single-finger gestures. If that is what you
want, they should receive "simultaneous" but different events.

"Ignoring the gesture will mean the gesture will never be offered to you
again. It *will *be offered to a parent widget or item as well." - from Qt
4.7 Gesture Overview
Documentation<http://doc.qt.nokia.com/latest/gestures-overview.html#standard-procedure-for-event-handling>
.

Therefore, if a QGraphicsObject ignores a gesture and has a QGraphicsObject,
the gesture event should be passed to the parent QGraphicsObject. Likewise,
if the parent of the QGraphicsObject is a QGraphicsScene, it should then be
passed to the parent scene. If the scene then ignores the event, it should
then be passed to the scenes parent (which might be the QGraphicsView). As I
understand the documentation, that should be the order of the
event propagation. It does not make sense for the scene or the view to
receive the gesture event on both sides of the QGraphicObject handling of
the event. Therefore, if scene should not receive the event until after the
QGraphicsObject ignores the event. That is my just opinion of how it should
be based on my limited knowledge of the Qt event loop documentation. Any
flows with that logic?

Regards,
Sean
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20110411/eb7a00eb/attachment.html 


More information about the Qt-interest-old mailing list