[Qt-interest] Multi Gesture

Sean Hayes sean.t.hayes at vanderbilt.edu
Mon Mar 21 17:33:55 CET 2011


Wathek,

All the touch points will go to all the gesture recognizers. As a result,
each gesture recognizer will have to determine which touch points that are
pertinent for triggering its gesture. I am not sure of the best method, but
here is one idea. Every touch point has a unique id (see
http://doc.qt.nokia.com/latest/qtouchevent-touchpoint.html#id). You can have
a data structure that associates a touch point with the gesture recognizers
(maybe a QHash<id, QGestureRecognizer*>). You could create an abstract class
that inherits QGestureRecognizer and that is itself inherited by all your
custom gesture recognizers. This class would contain a static instance of
you qtouchpoint data structure. That way all your gesture recognizer could
check the "ownership" of any touch points.

Sean

On Mon, Mar 21, 2011 at 10:00 AM, Wathek LOUED <wathek at gmail.com> wrote:

> Sean,
>
> Thank you for your response, I'd like to ask you if you got an idea how can
> I do to know to know which touch points are handled by which gesture
> recognizer because you know let's say I got two objects so two different
> instance of my gesture recognizer but the problem is that I don't think that
> I need to send all the time all the touched points to the gesture recognizer
> I need just to send the touched point that are contained into the object.
> You see what I mean ?
>
> Sincerely
> W.L
>
> On Sun, Mar 20, 2011 at 7:59 PM, Sean Hayes <sean.t.hayes at vanderbilt.edu>wrote:
>
>> Wathek,
>>
>> You are right, you only get the QGesture that is given to
>> the QGestureRecognizer and you cannot create two separate gestures of the
>> same type (as far as I know). I did not think about that before. However, a
>> unique QGesture is given to each QGestureRecognizer. Also,
>> each QGestureRecognizer receives all the events that all the
>> other QGestureRecognizers receive. Therefore, you should be able to have
>> simultanious gestures limited only by the number of
>> registered QGestureRecognizers.
>>
>> I have never tried this with the same gesture type, but you should be able
>> to get two gestures of the same type by registering two instances of that
>> gesture recognizer. This may only work for custom gestures (not the Qt's
>> built in ones) because each regestered QGestureRecognizer may need a unique
>> Qt::GestureType. That is just speculation. I am not sure how practical this
>> idea is, but I suspect it would work.
>>
>> Let me know what you think.
>>
>> Sean
>>
>>
>> On Sun, Mar 20, 2011 at 12:36 PM, Wathek LOUED <wathek at gmail.com> wrote:
>>
>>> Sean,
>>>
>>> Yes but the problem is that since that QGestureRecognizer doesn't free
>>> the QGesture and it uses always the same QGesture it only resets it I cannot
>>> have two (or more) same gestures at the same time.
>>>
>>> Let's say that the gesture is a Tap and Hold so it needs about 700ms
>>> without moving to recognize the gesture. So first touched Point the
>>> GestureRecognizer setted the QGesture parameters (Position, Timer, etc). At
>>> 400ms a second Touched Point arrived, the GestureRecognizer cannot do
>>> anything since it's busy with the first one. You see ?
>>>
>>>
>>> On Sun, Mar 20, 2011 at 5:44 PM, Wathek LOUED <wathek at gmail.com> wrote:
>>>
>>>> I see I got an other question. I'd like to know when the
>>>> QGestureRecognizer changes the QGesture::state to
>>>> QGestureRecognizer::CancelGesture or QGestureRecognizer::FinishGesture is
>>>> the QGesture killed ?
>>>>
>>>>  On Sun, Mar 20, 2011 at 3:53 PM, Sean Hayes <
>>>> sean.t.hayes at vanderbilt.edu> wrote:
>>>>
>>>>> Wathek,
>>>>>
>>>>> You could probably do  this by created you own gesture classes that
>>>>> subclass QGesture. The key would be how you recognize the gestures in your
>>>>> gesture recognizer. For example, you could monitor all the touch points
>>>>> received and see any one of them match your gestures (as opposed to only
>>>>> checking the first point or two). If you are use some gestures that utilize
>>>>> more than one touch point, you could test if any combinational of two points
>>>>> matches your gesture.
>>>>>
>>>>> Sean
>>>>>
>>>>> On Sun, Mar 20, 2011 at 7:38 AM, Wathek LOUED <wathek at gmail.com>wrote:
>>>>>
>>>>>> Hi all,
>>>>>>
>>>>>> I was thinking how can I do to get a multi gesture ? let's say a
>>>>>> finger to do a Tap And Hold Gesture and another finger where the user does a
>>>>>> Pan Gesture. Using the QGesture of Qt it won't work. Any idea how can I do
>>>>>> so that it'll be possible ?
>>>>>>
>>>>>> Thank you
>>>>>>
>>>>>> Sincerely
>>>>>> Wathek
>>>>>>
>>>>>> _______________________________________________
>>>>>> 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/20110321/4bb3d6f3/attachment.html 


More information about the Qt-interest-old mailing list