[Qt-interest] QTouchEvent/QGestureEvent propagation

Sean Hayes sean.t.hayes at vanderbilt.edu
Mon Apr 11 03:47:51 CEST 2011


I agree, the order the events are received in within the QGraphicsView is
counter intuitive.

I had a problem similar to this a while ago and I think I solved it by
adding a custom property to all my QGraphicsObjects (something link
receiveNextGesture). Then within the items I only handled the gesture if
that property was true. The property was set through my implementation of
QGraphicsView::sceneEvent(). The pseudocode for the sceneEvent() function
is:

if the event is a QGestureEvent

if the gesture has a hotspot

itemList = list of all items at the hotspot (see
http://doc.qt.nokia.com/latest/qgraphicsview.html#items-2)
if itemList.size() >= 1

itemList[0]->receiveNextGesture = true

for all the rest of the items in the list

itemList[iter]->receiveNextGesture = false


On Sun, Apr 10, 2011 at 3:33 PM, Wathek LOUED <wathek at gmail.com> 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 ?
>
> I'm trying to find a way to make it grabbed by only the most top element at
> the position (x, y) any one could help me for that please ?
>
> Thank you so much
>
> Sincerely
> W.L
>
> _______________________________________________
> Qt-interest mailing list
> Qt-interest at qt.nokia.com
> http://lists.qt.nokia.com/mailman/listinfo/qt-interest
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20110410/52b30482/attachment.html 


More information about the Qt-interest-old mailing list