summaryrefslogtreecommitdiffstats
path: root/examples/corelib/threads/mandelbrot/mandelbrotwidget.h
diff options
context:
space:
mode:
authorNicholas Bennett <nicholas.bennett@qt.io>2022-05-25 11:03:05 +0300
committerRami Potinkara <rami.potinkara@qt.io>2022-07-21 08:38:44 +0300
commitfc5482cac6e69364c9d09fb8d994065e2a5fb542 (patch)
tree9966a986452209566b4f5ff5fd13230dded51157 /examples/corelib/threads/mandelbrot/mandelbrotwidget.h
parenteb9ace1cee4bb48005797b0b2d2d3d576a4cb4ce (diff)
Support pinch zoom gesture in the Mandelbrot example
Used QGesture for this as per the gesture example. Moved the help and info text to separate lines. Enabled word wrap to prevent text going off screen. As a drive-by, the code to center the window at a size that's a fraction of the screen is replaced with a simple sizeHint() override. The user should have control over placement, particularly now that it should be placed manually onto a touchscreen if the user has one. Done-with: Shawn Rutledge Fixes: QTBUG-96702 Pick-to: 6.4 Change-Id: I8dba8b09bed474f585341e9a7a8c71fb60293eee Reviewed-by: Rami Potinkara <rami.potinkara@qt.io> Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
Diffstat (limited to 'examples/corelib/threads/mandelbrot/mandelbrotwidget.h')
-rw-r--r--examples/corelib/threads/mandelbrot/mandelbrotwidget.h8
1 files changed, 8 insertions, 0 deletions
diff --git a/examples/corelib/threads/mandelbrot/mandelbrotwidget.h b/examples/corelib/threads/mandelbrot/mandelbrotwidget.h
index 68c4a6f4f7..23c3a2bf40 100644
--- a/examples/corelib/threads/mandelbrot/mandelbrotwidget.h
+++ b/examples/corelib/threads/mandelbrot/mandelbrotwidget.h
@@ -4,6 +4,7 @@
#ifndef MANDELBROTWIDGET_H
#define MANDELBROTWIDGET_H
+#include <QGestureEvent>
#include <QPixmap>
#include <QWidget>
#include "renderthread.h"
@@ -18,6 +19,7 @@ public:
MandelbrotWidget(QWidget *parent = nullptr);
protected:
+ QSize sizeHint() const override { return {1024, 768}; };
void paintEvent(QPaintEvent *event) override;
void resizeEvent(QResizeEvent *event) override;
void keyPressEvent(QKeyEvent *event) override;
@@ -27,6 +29,9 @@ protected:
void mousePressEvent(QMouseEvent *event) override;
void mouseMoveEvent(QMouseEvent *event) override;
void mouseReleaseEvent(QMouseEvent *event) override;
+#ifndef QT_NO_GESTURES
+ bool event(QEvent *event) override;
+#endif
private slots:
void updatePixmap(const QImage &image, double scaleFactor);
@@ -34,6 +39,9 @@ private slots:
private:
void scroll(int deltaX, int deltaY);
+#ifndef QT_NO_GESTURES
+ bool gestureEvent(QGestureEvent *event);
+#endif
RenderThread thread;
QPixmap pixmap;