From 31cddefea97be65cdcc0970c237418b5b8a8e1d5 Mon Sep 17 00:00:00 2001 From: Benjamin Poulain Date: Fri, 2 Oct 2009 19:11:55 +0200 Subject: Add multitouch capabilities to the shared classes of the demo Add multitouch feature to the HoverPoints and the ArthurWidget. Multitouch is enabled by default for widgets using HoverPoints. The ArthurWidget propagate the TouchEvents in order to have them handled by a parent if a parent accept the touch events. Reviewed-by: Denis Dzyubenko Reviewed-by: Pierre Rossi --- demos/shared/arthurwidgets.h | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) (limited to 'demos/shared/arthurwidgets.h') diff --git a/demos/shared/arthurwidgets.h b/demos/shared/arthurwidgets.h index aa70002427..7b02bcd5c3 100644 --- a/demos/shared/arthurwidgets.h +++ b/demos/shared/arthurwidgets.h @@ -49,13 +49,32 @@ #if defined(QT_OPENGL_SUPPORT) #include +#include class GLWidget : public QGLWidget { public: GLWidget(QWidget *parent) - : QGLWidget(QGLFormat(QGL::SampleBuffers), parent) {} + : QGLWidget(QGLFormat(QGL::SampleBuffers), parent) + { + setAttribute(Qt::WA_AcceptTouchEvents); + } void disableAutoBufferSwap() { setAutoBufferSwap(false); } void paintEvent(QPaintEvent *) { parentWidget()->update(); } +protected: + bool event(QEvent *event) + { + switch (event->type()) { + case QEvent::TouchBegin: + case QEvent::TouchUpdate: + case QEvent::TouchEnd: + event->ignore(); + return false; + break; + default: + break; + } + return QGLWidget::event(event); + } }; #endif -- cgit v1.2.1