[Qt-interest] QGraphicsView with QGestureEvent

Elias Capito elias.capito at gmail.com
Mon Dec 7 19:11:53 CET 2009


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>

> 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>:
>>
>>
>>> 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.
>>
>>
>>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20091207/6513616c/attachment.html 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: TouchQGraphicsObject.zip
Type: application/zip
Size: 9233 bytes
Desc: not available
Url : http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20091207/6513616c/attachment.zip 


More information about the Qt-interest-old mailing list