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
[email protected]
http://lists.trolltech.com/mailman/listinfo/qt4-preview-feedback