Stacking QGesture-s



  • My question here is basically how to deal with the situation described below and how to stack gesture events. This would allow me to create composite gestures which are basically a specific set of gestures done in a specific order.

    I want to create a double swipe gesture, which is basically two consecutive normal swipes in the same direction within a given time limit. There are multiple cases that need to be considered here namely

    • Two single swipes in the same direction within the time limit - here we have a double swipe and we interpret the gestures as such
    • Single swipe is captured however timeout kicks in - we moved our hand north to south triggering a swipe gesture event however the next swipe gesture event takes place after the timeout. In this case we interpret the situation as two separate single swipes one after the other
    • Two single swipes within the time limit but in different directions - we move our hand north to south but right after that east to west. All is within the given time limit but it's not a double swipe according to the definition hence we interpret the gestures are two single swipes
    • Single swipe is captured followed by another gesture of a different type - let's say there is support for tap and whatever other gestures there are for the given scenario. Even if we make another swipe gesture in the same direction within the time limit (that is swipe -> tap -> swipe all fit in that interval) we don't have a double gesture again because of the definition.

    Given that gesture recognizers are state-based one can probably simply capture a single swipe, toggle a flag (which says "One swipe is done, one more to go" + start the timer for the time limit resetting that flag upon timeout or if another interruption is triggered) and then wait for the next. However there is the issue with the generic swipe gesture recognizer that is shipped with the Qt Gesture API. If a swipe gesture event is emitted, that recognizer will capture it, see that it's a swipe gesture and accept it leaving the double swipe recognizer in a situation where it does toggle that flag but the single swipe has already been processed and the application has reacted to it. Disabling the generic swipe gesture recognizer would mean that 1)no single swipe gesture events will be process or 2)I have to write my own single swipe gesture recognizer (or use the double swipe recognizer to handle both single and double swipe events).

    On the other hand as mentioned in the last case above I also have multiple other gestures including custom ones which obviously need to be taken into consideration while waiting for that second swipe.

    Note that according to the Qt documentation QGestures are owned by Qt and should not be stored aside or deleted manually. The documentation goes even further and states that gestures are created when needed that is instantiation is implicit. I do believe that this applies only to the normal use case such as writing an application for a generic touch screen. In my case I have a device that recognizes 3D gestures and emits that data in its own non-Qt-ish format which obviously needs to be converted and integrated into the Qt Gesture API. Due to the "great" Qt documentation on the topic of gesture recognition I ever so often think about dumping the whole thing and doing a standard slot-signal thing however it is definitely preferable to be able to expand the standard Qt Gesture API with custom gestures and expose the desired gesture functionality as if it's a out-of-the-box and handled just like the already present Swipe and Tap gestures that are part of the Qt Gesture API.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.