Hello Everyone,
I pretty new to Qt but I've wrote a few small gadgets, for the last couple of weeks I've been trying to figure out how grab touch gestures using a Graphics View and so far I haven't had any luck. I am running Qt 4.6 using the Creator, I found an example that came with Qt SDK 2010 that does this using QPainter (Gestures example) but I am interested in using GraphicsView with GraphicsObjects (images, etc).
Right now I have a class definition that looks like this:
class MultiTouchWidget : public QWidget, public QAbstractScrollArea
{
Q_OBJECT
public:
MultiTouchWidget(QWidget *parent = 0);
QGraphicsView *MainGraphicsView;
protected:
//bool event(QEvent *event);
bool viewportEvent(QEvent *event);
private:
bool gestureEvent(QGestureEvent *event);
void pinchTriggered(QPinchGesture *);
};
I create an instance of the class in the main window and then in the class constructor I create an instance of the MainGraphicsView along with a scene, I use grabGesture on the MainGraphicsView and it's viewport() I've also tried grabbing gestures from the MutiTouchWidget class itself. I set WA_AcceptTouchEvents on the viewport() of the main class as well as GraphicsView and it's viewport().
Then I reimplemented viewportEvent() to look for GestureEvents, but when I put a breakpoint in the function I never get gesture events there, otherthan that everything is working I see the items in the view but the touch gestures are never received. Also when I try to pan around or try some gestures on the Graphics View a lot of times I get an error that looks something like this:
Debug Error!
Project....
Line: 2230
ASSERT: !isEmpty() in file
....qlist.h line 263
What am I doing wrong? I've been looking everywhere on the web to find a good tutorial to use TouchGestures with GraphicsView but I haven't found anything available, can somebody help me out? If you know a good tutorial on this or have an example, please share.
Thanks in advance.
Bookmarks