[Qt-interest] QGraphicsView with QGestureEvent

Martin Guillon MGuillon at movea.com
Thu Dec 10 14:21:29 CET 2009


Wow what a shame, I don't see why we couldn't :s
In fact I found an article about mouse gestures on the Qt blog:
http://doc.trolltech.com/qq/qq18-mousegestures.html#runningtheexample
And it s really really similar to QGesture so I thought ....

But thanks anyway

Martin


-----Original Message-----
From: Raymond de Vries [mailto:reedev at xs4all.nl] 
Sent: Thursday, December 10, 2009 9:37 AM
To: Martin Guillon
Cc: Elias Capito; qt-interest at trolltech.com
Subject: Re: [Qt-interest] QGraphicsView with QGestureEvent

Hi Martin,

I am certainly not (yet) an expert with Qt gestures but afaik this is not possible. E.g. the calculations are done based on multiple touchpoints.

Regards
Raymond


Martin Guillon wrote:
> Hi,
>
> I am discovering through this conversation and the help the power of gestures. Now one thing I need that seems possible but I don't know how:  Can you do gestures with the mouse?
> Like right clik, move, release?
>
> Thanks
>
> -----Original Message-----
> From: qt-interest-bounces at trolltech.com 
> [mailto:qt-interest-bounces at trolltech.com] On Behalf Of Raymond de 
> Vries
> Sent: Tuesday, December 08, 2009 9:29 PM
> To: Elias Capito
> Cc: qt-interest at trolltech.com
> Subject: Re: [Qt-interest] QGraphicsView with QGestureEvent
>
> Hi Elias,
>
> Thanks for pointing at the knob example. I've looked a lot at the 
> various examples but it was never clear how the multitouch and gesture 
> classes work together. Living on the edge, obviously ;-)
>
> Thanks again, I will take a look at it and combine the examples.
>
> Best regards
> Raymond
>
>
>
>
> Elias Capito wrote:
>   
>> Hi Raymond,
>>
>> Yes, I can use the events QTouchEvent in place of QGestureEvent, both 
>> they are not compatible, because the gesture need the touch point.
>>
>> To manage the touchpoint yourself, you need just use
>> setAcceptTouchEvent(true) in your QGraphicsObject and implement the 
>> method QGraphicsObject::sceneEvent(...). So, you don't need to play 
>> with the viewport for the touchpoint.
>>
>> In directory Example of Qt, you can see the directory multitouch, 
>> inside there is some example using QTouchEvent, the most interessant 
>> is knobs.
>>
>> Best regards
>> Elias
>>
>>
>> 2009/12/8 Raymond de Vries <reedev at xs4all.nl 
>> <mailto:reedev at xs4all.nl>>
>>
>>     Hi Elias,
>>
>>     I can't tell from your messages but are you using multitouch
>>     (without the gesture classes) now with graphicsview and some
>>     graphicsobjects on it? Is that so? It might be possible to do
>>     multitouch yourself (so without gestures) but I have not yet found
>>     out how to distinguish between the graphicsview (and it's
>>     viewport) and the graphics items on it.
>>
>>     I would love to find out how that works, even with pure multitouch
>>     events.
>>
>>     thanks, best regards
>>     Raymond
>>
>>
>>
>>     Elias Capito wrote:
>>
>>         Hi,
>>
>>         I am using Qt 4.6.0 on Windows 7 x64, who is installed on a
>>         Dell Latitude XT with the last N-Trig driver.
>>
>>         Is not related with the topic, but if you can answer, it would
>>         be good.
>>
>>         I have a question about the gesture QSwipeGesture and
>>         QTapAndHoldGesture, the first are sometimes detect when I do
>>         strange gesture with many fingers, but I don't know how :D and
>>         the second is never detect, but the match in Windows is detect.
>>
>>         Best regards
>>         Elias
>>
>>         2009/12/8 Raymond de Vries <reedev at xs4all.nl
>>         <mailto:reedev at xs4all.nl> <mailto:reedev at xs4all.nl
>>         <mailto:reedev at xs4all.nl>>>
>>
>>
>>            Hi,
>>
>>            Ok, I can confirm this here too with your sample application as
>>            well as my own application. Fyi, I am using my own built
>>            qt-everywhere-opensource-src-4.6.0 on Windows 7, Visual
>>         Studio 9
>>            2008. I'm sorry that I did not get your (by Denis) first
>>         remark to
>>            grab the getures with the *viewport*, I was doing it on the
>>            graphicsview directly (which resulted in the same asserion
>>         btw).
>>
>>            Any hints or tips are welcome.
>>
>>            best regards
>>            Raymond
>>
>>
>>
>>            Elias Capito wrote:
>>
>>
>>                Thanks for your reply Denis.
>>
>>                I have add the all gesture to the viewport with
>>                viewport()->grabGesture(...) in QGraphicsView and to my
>>         item,
>>                but when I debug my application any gesture are
>>         delivered to
>>                the items.
>>
>>                I have tested with QGraphicsView and my own herited
>>         class of
>>                QGraphicsView.
>>
>>                I have the following error when I make a gesture on an item
>>                and after i touch the viewport (not an item) : *ASSERT:
>>                "!isEmpty<>" ..
>>
>>                *
>>                I add the source code* *in attachement*.
>>                *
>>
>>                Best regards
>>
>>                2009/12/7 Raymond de Vries <reedev at xs4all.nl
>>         <mailto:reedev at xs4all.nl>
>>                <mailto:reedev at xs4all.nl <mailto:reedev at xs4all.nl>>
>>         <mailto:reedev at xs4all.nl <mailto:reedev at xs4all.nl>
>>
>>                <mailto:reedev at xs4all.nl <mailto:reedev at xs4all.nl>>>>
>>
>>
>>                   Hi Denis,
>>
>>                   I was also following this thread and I tried the
>>         same, with
>>                   QGraphicsWebView but even with your advice, I don't
>>         get the
>>                   gesture events...
>>
>>                   This is what you mean to do:
>>                   MTCanvas : public QGraphicsView
>>                   constructor
>>                    viewport()->setAttribute(Qt::WA_AcceptTouchEvents);
>>                    grabGesture(Qt::PanGesture);
>>                    grabGesture(Qt::PinchGesture);
>>                    grabGesture(Qt::SwipeGesture);
>>                    etc
>>                   MTCancas::event() does receive Gesture events
>>
>>                   MTWebBrowser : public QGraphicsWebView
>>                   constructor
>>                    setAcceptTouchEvents(true);
>>                    grabGesture(Qt::PanGesture);
>>                    grabGesture(Qt::PinchGesture);
>>                    grabGesture(Qt::SwipeGesture);
>>                    etc
>>                   MTWebBrowser::event(QEvent *event) does not receive
>>         Gesture
>>                events
>>
>>                   Is this supposed to work?
>>
>>                   Thanks a lot, best regards
>>                   Raymond
>>
>>
>>
>>
>>
>>                   Denis Dzyubenko wrote:
>>
>>                       Hi Elias,
>>
>>                       2009/12/3 Elias Capito <elias.capito at gmail.com
>>         <mailto:elias.capito at gmail.com>
>>                <mailto:elias.capito at gmail.com
>>         <mailto:elias.capito at gmail.com>>
>>                       <mailto:elias.capito at gmail.com
>>         <mailto:elias.capito at gmail.com>
>>                <mailto:elias.capito at gmail.com
>>         <mailto:elias.capito at gmail.com>>>>:
>>
>>                                         I want to do a multitouch
>>         application.
>>
>>                           I have a problem with the QGestureEvent on a
>>                           QGraphicsObject item . I use
>>                           "grabGesture" on my item in constructor and
>>         i debug
>>                to see
>>                           the input event.
>>
>>                           When I run the application, the
>>         QGestureEvent never
>>                           appear, but if I use
>>                           QTouchEvent on item in place of
>>         QGestureEvent, with
>>                           "setAcceptTouchEvent",
>>                           in my debug I can see the touch event.
>>
>>                           If I use QGestureEvent with a simple QWidget
>>         and I
>>                run it,
>>                           I can see the
>>                           gesture event, so i think it's correct.
>>
>>                           It's the first time, that I use
>>         QGraphicsView, so I
>>                think
>>                           i have miss
>>                           something.
>>
>>                           Anyone have an idea, why the QGestureEvent not
>>                appear on
>>                           my item ?
>>                            
>>                       right now to get gesture events on a
>>         QGraphicsObject it
>>                should
>>                       subscribe to a gesture _and_ the viewport of the
>>                graphicsview
>>                       should
>>                       also explicitly subscribe to the same gesture.
>>                Apparently it isn't
>>                       documented right now, sorry about that. Anyway,
>>         I this
>>                will be
>>                       improved in future versions of Qt so that you
>>         will not
>>                have to
>>                       do that
>>                       manually (thank god I forgot to document that,
>>         so we can
>>                       change the
>>                       behavior ;) )
>>
>>                       However for now you need to make sure the
>>         viewport also
>>                       subscribes to
>>                       the same gesture type.
>>
>>                      
>>
>>
>>
>>
>>
>>     
>
> _______________________________________________
> Qt-interest mailing list
> Qt-interest at trolltech.com
> http://lists.trolltech.com/mailman/listinfo/qt-interest
>
>   





More information about the Qt-interest-old mailing list