[Qt-interest] cannot grab gesture with qgraphicsobject

Sean Hayes sean.t.hayes at vanderbilt.edu
Mon Mar 7 21:29:41 CET 2011


Wathek,

Try calling grabGesture(tapGesture) in both the viewport and the
QGraphicsObject. Also, you probably do not need the
setAcceptTouchEvents(true) statement. Also, make sure your TapGesture has a
defined hotspot (see
http://doc.qt.nokia.com/latest/qgesture.html#hotSpot-prop).

Sean

On Mon, Mar 7, 2011 at 12:31 PM, Wathek LOUED <wathek at gmail.com> wrote:

> Hi,
>
> I got a problem with QGraphicsObject, I cannot grab gesture and I'm getting
> this message : QGestureManager::deliverEvent: could not find the target for
> gesture.
>
> I put in the constructor :
>
> setAcceptTouchEvents(true);
> tapGestureRecognizer = new TapGestureRecognizer();
> tapGesture = QGestureRecognizer::registerRecognizer(tapGestureRecognizer);
> grabGesture(tapGesture);
>
>
> and I reimplemented the bool QGraphicsItem::sceneEvent(QEvent *) function :
>
> bool PushButtonItem::sceneEvent(QEvent *event)
> {
> qDebug("Event received");
> if (event->type() == QEvent::Gesture)
> gestureEvent(static_cast<QGestureEvent *>(event));
>
>         return true;
> }
>
> void PushButtonItem::gestureEvent(QGestureEvent *event)
> {
> if (event->gesture(tapGesture))
>  qDebug("button Tapped");
> }
>
>
> the same code works well when I use it with the viewport of my
> QGraphicsView but it doesn't work with QGraphicsObject. Any idea ?
>
> Thank you so much
>
> 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/20110307/f7c6f665/attachment.html 


More information about the Qt-interest-old mailing list