Results 1 to 2 of 2

Thread: TapAndHold gesture wrongly generated

  1. #1
    Join Date
    Dec 2009
    Posts
    29
    Thanks
    2
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default TapAndHold gesture wrongly generated

    Hello,

    I am having the following problem with tapAndHold gesture:

    I have 2 QGraphicsItems in a QGraphicsScene. One of them have a Z-Value of 100, the other one has 90. Both of them are selectable. They also both grab tapGesture and tapAndHoldGesture.

    I want to catch tapAndHoldGesture in order to display a contextual menu. That is working. If my 2 QGraphicsItems are not overlapping (i.e. their shape() are not overlapping), then I don't have any problem when I simply tap on one of the items (it becomes selected as it should). But when I do a simple tap on the item with 100 z-value and the item with 90 z-value is beneath, then after 10secs (I have specified QTapAndHoldTimeOut(10000) ), I get a unexpected tapAndHold event for the item I have tapped, although I am not touching the screen anymore.

    Note that if I generate the tapAndHoldGesture with a long mouse click instead of a long tap on the screen, this problem does not appear and every thing behave as it should. The wrong tapAndHoldGesture is generated only after a short tap on the screen if items shapes are overlapping.

    I have tested this behavior with both Android and Windows 7, using QT 5.2.1. It seems to me that in that case for some reason the tapAndHold gesture timer is not stopped.

    With some qWarning() inside sceneEvent(), I can see that the sequence when I touch the top item is the following:
    (item1 is the item in front of item2)

    item1 202 (gestureOverride)
    item2 202 (gestureOverride)
    item1 198 (gesture - tapGesture with state()==GestureStarted)
    item1 202 (gestureOverride)
    item2 202 (gestureOverride)
    item1 198 (gesture - tapGesture with state()==GestureStarted)
    item2 194 (touch begin)
    item1 186 (mouse move)
    item1 186 (grab mouse)
    item1 156 (mouse pressed)
    item1 198 (gesture - tapGesture with state()==GestureFinished)
    item1 157 (mouse released)
    item1 197 (ungrab mouse)
    item1 202 (gesture override)
    item2 202 (gesture override)
    item1 198 (gesture - tapAndHoldGesture with state()==GestureStarted)
    item1 198 (gesture - tapAndHoldGesture with state()==GestureFinished)

    I have tried a lot of various combinations of accepting/ignoring event or gesture or gestureOverride with no luck.

    Finally what I did to turn around this problem is that I check that the item is the scene's mouse grabber and if this is not the case I ignore the tapAndHoldGesture. But this is a bad hack imo.

    Should I fill a bug report? Maybe someone else has this kind of things working and I did something wrong?

    Thanks
    Philippe.

  2. #2
    Join Date
    Apr 2012
    Posts
    13
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: TapAndHold gesture wrongly generated

    I don't have it working and I have no experience with Tap or TapAndHold. But that does seem strange.

    I looked at the code for those two recognizers. My understanding is: when the TapAndHold recognizer gets a TouchEnd or MouseRelease before its timer goes off, the gesture is canceled, and Qt will call the reset() method of the recognizer, which does stop the timer. In your sequence above, there IS a mouse release that should have canceled the T&H gesture (which was in the maybe state.)

    Maybe it is a bug, a subtle condition that the designers didn't anticipate. It must be related to the overlapping, which is related to the GestureOverride, which I don't understand and which is not documented.

    Have you tried setCancelPolicy(CancelAllInContext) when the Tap is recognized?

Similar Threads

  1. Swipe gesture not recognized
    By Luc4 in forum Qt Programming
    Replies: 2
    Last Post: 16th December 2014, 15:13
  2. How to implement mouse gesture by qt
    By redstoneleo in forum Qt Programming
    Replies: 0
    Last Post: 10th January 2013, 03:37
  3. How to implement mouse gesture by qt
    By redstoneleo in forum Newbie
    Replies: 0
    Last Post: 10th January 2013, 03:34
  4. Day showing wrongly in thread list in NewBie
    By karthic in forum General Discussion
    Replies: 1
    Last Post: 29th April 2012, 14:06
  5. Gesture Programming specs
    By scarleton in forum Qt Programming
    Replies: 3
    Last Post: 5th December 2010, 23:30

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.