is gesture classes only supported by some platforms or are all platforms supported?
From what I understand, multi-touch gestures are only supported on some platforms such as Windows 7.
The docs in 4.6 seem to suggest gestures work for graphic view's objects too.
That is what confuses me. I am using Qt 4.6.3 and yet I get no QGestureEvents from my QGraphicsObject.
Here is a full QGraphicsObject to test gestures with. Take a look and see if I am missing something. If someone else could test test it themselves that would be great! I just added it to a standard QGraphicsScene. I am compiling 4.7 beta now and will give that a try.
#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::PanGesture);
grabGesture(Qt::SwipeGesture);
}
return QRectF(-WIDTH
/ 2,
-HEIGHT
/ 2, WIDTH, HEIGHT
);
}
path.addEllipse(boundingRect());
return path;
}
pOption;
pWidget;
painter->setBrush(Qt::blue);
painter->drawEllipse(boundingRect());
}
bool sceneEvent
(QEvent* pEvent
) { std::cout << "Gesture Event Received from sceneEvent()" << std::endl;
}
return QGraphicsObject::sceneEvent(pEvent);
}
switch (pEvent->type()) {
std::cout << "Gesture Event Received from event()" << std::endl;
}
return QGraphicsObject::event(pEvent);
}
private:
static const int WIDTH = 80;
static const int HEIGHT = 80;
};
#endif
#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::PanGesture);
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) {
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 = 80;
static const int HEIGHT = 80;
};
#endif
To copy to clipboard, switch view to plain text mode
Bookmarks