diff options
Diffstat (limited to 'examples/gestures/imageviewer/imagewidget.cpp')
-rw-r--r-- | examples/gestures/imageviewer/imagewidget.cpp | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/examples/gestures/imageviewer/imagewidget.cpp b/examples/gestures/imageviewer/imagewidget.cpp index f3fd8e4..c4a4e50 100644 --- a/examples/gestures/imageviewer/imagewidget.cpp +++ b/examples/gestures/imageviewer/imagewidget.cpp @@ -59,17 +59,21 @@ ImageWidget::ImageWidget(QWidget *parent) setAttribute(Qt::WA_OpaquePaintEvent); setAttribute(Qt::WA_NoSystemBackground); +//! [enable gestures] grabGesture(Qt::PanGesture); grabGesture(Qt::PinchGesture); grabGesture(Qt::SwipeGesture); +//! [enable gestures] } +//! [event handler] bool ImageWidget::event(QEvent *event) { if (event->type() == QEvent::Gesture) return gestureEvent(static_cast<QGestureEvent*>(event)); return QWidget::event(event); } +//! [event handler] void ImageWidget::paintEvent(QPaintEvent*) { @@ -98,6 +102,7 @@ void ImageWidget::mouseDoubleClickEvent(QMouseEvent *) update(); } +//! [gesture event handler] bool ImageWidget::gestureEvent(QGestureEvent *event) { if (QGesture *pan = event->gesture(Qt::PanGesture)) { @@ -112,6 +117,7 @@ bool ImageWidget::gestureEvent(QGestureEvent *event) } return false; } +//! [gesture event handler] void ImageWidget::panTriggered(QPanGesture *gesture) { @@ -147,7 +153,7 @@ void ImageWidget::pinchTriggered(QPinchGesture *gesture) update(); } -//! [swipe slot] +//! [swipe function] void ImageWidget::swipeTriggered(QSwipeGesture *gesture) { if (gesture->horizontalDirection() == QSwipeGesture::Left @@ -157,7 +163,7 @@ void ImageWidget::swipeTriggered(QSwipeGesture *gesture) goNextImage(); update(); } -//! [swipe slot] +//! [swipe function] void ImageWidget::resizeEvent(QResizeEvent*) { |