qt4-preview-feedback@trolltech.com
[Top] [All Lists]

[Qt4-preview-feedback] Gestures not received on QGraphicsObjects

Subject: [Qt4-preview-feedback] Gestures not received on QGraphicsObjects
From: Sean Hayes
Date: Thu, 17 Jun 2010 22:19:35 -0500
I am having problems getting any QGestureEvents on a QGraphicsObjects.
I think these events are not getting propagated properly. Here is an
example/test of an object that does not receive any QGestureEvents
that it grabs. Is this a Qt bug? I am using Qt 4.6.3 on Windows 7
(also tried Qt 4.7.0 beta 1).

#ifndef ___TOUCHOBJECT___
#define ___TOUCHOBJECT___

#include <QtGui>
#include <iostream>

class TouchObject : public QGraphicsObject {
       Q_OBJECT
public:
       TouchObject(QGraphicsItem* pParent = NULL) : QGraphicsObject(pParent) {
               grabGesture(Qt::PinchGesture);
               grabGesture(Qt::PanGestures);
               grabGesture(Qt::SwipeGesture);
       }

       QRectF boundingRect() const {
               return QRectF(-WIDTH / 2, -HEIGHT / 2, WIDTH, HEIGHT);
       }

       QPainterPath shape() const {
               QPainterPath path;
               path.addEllipse(boundingRect());
               return path;
       }

       void paint(QPainter *painter, const QStyleOptionGraphicsItem
*pOption, QWidget *pWidget) {
               pOption;
               pWidget;
               painter->setBrush(Qt::blue);
               painter->drawEllipse(boundingRect());
       }


       bool sceneEvent(QEvent* pEvent) {
               switch (pEvent->type()) {
                       case QEvent::Gesture:
                               std::cout << "Gesture Event Received
from sceneEvent()" << std::endl;
               }

               return QGraphicsObject::sceneEvent(pEvent);
       }

       bool event(QEvent* pEvent) {
               switch (pEvent->type()) {
                       case QEvent::Gesture:
                               std::cout << "Gesture Event Received
from event()" << std::endl;
               }

               return QGraphicsObject::event(pEvent);
       }


private:
       static const int WIDTH = 160;
       static const int HEIGHT = 160;
};

#endif
_______________________________________________
Qt4-preview-feedback mailing list
Qt4-preview-feedback@xxxxxxxxxxxxx
http://lists.trolltech.com/mailman/listinfo/qt4-preview-feedback

<Prev in Thread] Current Thread [Next in Thread>