summaryrefslogtreecommitdiffstats
path: root/examples/widgets/painting
diff options
context:
space:
mode:
authorOlivier Goffart <ogoffart@woboq.com>2014-07-14 09:13:02 +0200
committerOlivier Goffart <ogoffart@woboq.com>2014-07-15 08:44:44 +0200
commit3b0c2b7c1b3ccdfe6867884a7e210bfc63e10f84 (patch)
tree4c75a4fa9f023c4bfc6746a4412922a8efe3b017 /examples/widgets/painting
parent6d87e3ed40173eac8c275d5926266359d53c74c7 (diff)
Examples: Add Q_DECL_OVERRIDE to overridden functions
Q_DECL_OVERRIDE (which expands to 'override' for supported compiler) helps to declare the intent (that it is an overridden function) and force compilation error when there is no such virtual function in the base class. The examples should show the best practice of having it, as it may save the programmer quite some time in case of change of API or typo in the function name or arguments. This change was done automatically with clang-modernize -add-override -override-macros And fixed MSVC compilation by removing inline for TorrentViewDelegate::paint Change-Id: Ice66ae93fae571266f908703d5b8892b2c1ebb1a Reviewed-by: Jędrzej Nowacki <jedrzej.nowacki@digia.com>
Diffstat (limited to 'examples/widgets/painting')
-rw-r--r--examples/widgets/painting/affine/xform.h12
-rw-r--r--examples/widgets/painting/basicdrawing/renderarea.h6
-rw-r--r--examples/widgets/painting/composition/composition.h12
-rw-r--r--examples/widgets/painting/concentriccircles/circlewidget.h6
-rw-r--r--examples/widgets/painting/deform/pathdeform.h12
-rw-r--r--examples/widgets/painting/gradients/gradients.h10
-rw-r--r--examples/widgets/painting/painterpaths/renderarea.h6
-rw-r--r--examples/widgets/painting/pathstroke/pathstroke.h16
-rw-r--r--examples/widgets/painting/shared/arthurstyle.h20
-rw-r--r--examples/widgets/painting/shared/arthurwidgets.h8
-rw-r--r--examples/widgets/painting/shared/hoverpoints.h2
-rw-r--r--examples/widgets/painting/transformations/renderarea.h6
12 files changed, 58 insertions, 58 deletions
diff --git a/examples/widgets/painting/affine/xform.h b/examples/widgets/painting/affine/xform.h
index 67ebf43689..46038b29fd 100644
--- a/examples/widgets/painting/affine/xform.h
+++ b/examples/widgets/painting/affine/xform.h
@@ -71,14 +71,14 @@ public:
enum XFormType { VectorType, PixmapType, TextType };
XFormView(QWidget *parent);
- void paint(QPainter *);
+ void paint(QPainter *) Q_DECL_OVERRIDE;
void drawVectorType(QPainter *painter);
void drawPixmapType(QPainter *painter);
void drawTextType(QPainter *painter);
- QSize sizeHint() const { return QSize(500, 500); }
+ QSize sizeHint() const Q_DECL_OVERRIDE { return QSize(500, 500); }
- void mousePressEvent(QMouseEvent *e);
- void resizeEvent(QResizeEvent *e);
+ void mousePressEvent(QMouseEvent *e) Q_DECL_OVERRIDE;
+ void resizeEvent(QResizeEvent *e) Q_DECL_OVERRIDE;
HoverPoints *hoverPoints() { return pts; }
bool animation() const { return timer.isActive(); }
@@ -115,9 +115,9 @@ signals:
void shearChanged(int shear);
protected:
- void timerEvent(QTimerEvent *e);
+ void timerEvent(QTimerEvent *e) Q_DECL_OVERRIDE;
#ifndef QT_NO_WHEELEVENT
- void wheelEvent(QWheelEvent *);
+ void wheelEvent(QWheelEvent *) Q_DECL_OVERRIDE;
#endif
private:
diff --git a/examples/widgets/painting/basicdrawing/renderarea.h b/examples/widgets/painting/basicdrawing/renderarea.h
index 3975ddbbe3..e39db21d32 100644
--- a/examples/widgets/painting/basicdrawing/renderarea.h
+++ b/examples/widgets/painting/basicdrawing/renderarea.h
@@ -57,8 +57,8 @@ public:
RenderArea(QWidget *parent = 0);
- QSize minimumSizeHint() const;
- QSize sizeHint() const;
+ QSize minimumSizeHint() const Q_DECL_OVERRIDE;
+ QSize sizeHint() const Q_DECL_OVERRIDE;
public slots:
void setShape(Shape shape);
@@ -68,7 +68,7 @@ public slots:
void setTransformed(bool transformed);
protected:
- void paintEvent(QPaintEvent *event);
+ void paintEvent(QPaintEvent *event) Q_DECL_OVERRIDE;
private:
Shape shape;
diff --git a/examples/widgets/painting/composition/composition.h b/examples/widgets/painting/composition/composition.h
index b52cc51681..610017a5d8 100644
--- a/examples/widgets/painting/composition/composition.h
+++ b/examples/widgets/painting/composition/composition.h
@@ -109,21 +109,21 @@ class CompositionRenderer : public ArthurFrame
public:
CompositionRenderer(QWidget *parent);
- void paint(QPainter *);
+ void paint(QPainter *) Q_DECL_OVERRIDE;
void setCirclePos(const QPointF &pos);
- QSize sizeHint() const { return QSize(500, 400); }
+ QSize sizeHint() const Q_DECL_OVERRIDE { return QSize(500, 400); }
bool animationEnabled() const { return m_animation_enabled; }
int circleColor() const { return m_circle_hue; }
int circleAlpha() const { return m_circle_alpha; }
protected:
- void mousePressEvent(QMouseEvent *);
- void mouseMoveEvent(QMouseEvent *);
- void mouseReleaseEvent(QMouseEvent *);
- void timerEvent(QTimerEvent *);
+ void mousePressEvent(QMouseEvent *) Q_DECL_OVERRIDE;
+ void mouseMoveEvent(QMouseEvent *) Q_DECL_OVERRIDE;
+ void mouseReleaseEvent(QMouseEvent *) Q_DECL_OVERRIDE;
+ void timerEvent(QTimerEvent *) Q_DECL_OVERRIDE;
public slots:
void setClearMode() { m_composition_mode = QPainter::CompositionMode_Clear; update(); }
diff --git a/examples/widgets/painting/concentriccircles/circlewidget.h b/examples/widgets/painting/concentriccircles/circlewidget.h
index a1ca3dfe43..f09ab10a48 100644
--- a/examples/widgets/painting/concentriccircles/circlewidget.h
+++ b/examples/widgets/painting/concentriccircles/circlewidget.h
@@ -54,14 +54,14 @@ public:
void setFloatBased(bool floatBased);
void setAntialiased(bool antialiased);
- QSize minimumSizeHint() const;
- QSize sizeHint() const;
+ QSize minimumSizeHint() const Q_DECL_OVERRIDE;
+ QSize sizeHint() const Q_DECL_OVERRIDE;
public slots:
void nextAnimationFrame();
protected:
- void paintEvent(QPaintEvent *event);
+ void paintEvent(QPaintEvent *event) Q_DECL_OVERRIDE;
private:
bool floatBased;
diff --git a/examples/widgets/painting/deform/pathdeform.h b/examples/widgets/painting/deform/pathdeform.h
index c5c86d1017..f89c5a2c86 100644
--- a/examples/widgets/painting/deform/pathdeform.h
+++ b/examples/widgets/painting/deform/pathdeform.h
@@ -60,14 +60,14 @@ class PathDeformRenderer : public ArthurFrame
public:
explicit PathDeformRenderer(QWidget *widget, bool smallScreen = false);
- void paint(QPainter *painter);
+ void paint(QPainter *painter) Q_DECL_OVERRIDE;
- void mousePressEvent(QMouseEvent *e);
- void mouseReleaseEvent(QMouseEvent *e);
- void mouseMoveEvent(QMouseEvent *e);
- void timerEvent(QTimerEvent *e);
+ void mousePressEvent(QMouseEvent *e) Q_DECL_OVERRIDE;
+ void mouseReleaseEvent(QMouseEvent *e) Q_DECL_OVERRIDE;
+ void mouseMoveEvent(QMouseEvent *e) Q_DECL_OVERRIDE;
+ void timerEvent(QTimerEvent *e) Q_DECL_OVERRIDE;
- QSize sizeHint() const { return QSize(600, 500); }
+ QSize sizeHint() const Q_DECL_OVERRIDE { return QSize(600, 500); }
bool animated() const { return m_animated; }
int radius() const { return int(m_radius); }
diff --git a/examples/widgets/painting/gradients/gradients.h b/examples/widgets/painting/gradients/gradients.h
index ee719bb3c2..7d9aa9c1e6 100644
--- a/examples/widgets/painting/gradients/gradients.h
+++ b/examples/widgets/painting/gradients/gradients.h
@@ -67,9 +67,9 @@ public:
void setGradientStops(const QGradientStops &stops);
- void paintEvent(QPaintEvent *e);
+ void paintEvent(QPaintEvent *e) Q_DECL_OVERRIDE;
- QSize sizeHint() const { return QSize(150, 40); }
+ QSize sizeHint() const Q_DECL_OVERRIDE { return QSize(150, 40); }
QPolygonF points() const;
HoverPoints *hoverPoints() const { return m_hoverPoints; }
@@ -116,12 +116,12 @@ class GradientRenderer : public ArthurFrame
public:
GradientRenderer(QWidget *parent);
- void paint(QPainter *p);
+ void paint(QPainter *p) Q_DECL_OVERRIDE;
- QSize sizeHint() const { return QSize(400, 400); }
+ QSize sizeHint() const Q_DECL_OVERRIDE { return QSize(400, 400); }
HoverPoints *hoverPoints() const { return m_hoverPoints; }
- void mousePressEvent(QMouseEvent *e);
+ void mousePressEvent(QMouseEvent *e) Q_DECL_OVERRIDE;
public slots:
void setGradientStops(const QGradientStops &stops);
diff --git a/examples/widgets/painting/painterpaths/renderarea.h b/examples/widgets/painting/painterpaths/renderarea.h
index 02d0adb1ec..be5de5952d 100644
--- a/examples/widgets/painting/painterpaths/renderarea.h
+++ b/examples/widgets/painting/painterpaths/renderarea.h
@@ -52,8 +52,8 @@ class RenderArea : public QWidget
public:
explicit RenderArea(const QPainterPath &path, QWidget *parent = 0);
- QSize minimumSizeHint() const;
- QSize sizeHint() const;
+ QSize minimumSizeHint() const Q_DECL_OVERRIDE;
+ QSize sizeHint() const Q_DECL_OVERRIDE;
public slots:
void setFillRule(Qt::FillRule rule);
@@ -63,7 +63,7 @@ public slots:
void setRotationAngle(int degrees);
protected:
- void paintEvent(QPaintEvent *event);
+ void paintEvent(QPaintEvent *event) Q_DECL_OVERRIDE;
//! [0]
//! [1]
diff --git a/examples/widgets/painting/pathstroke/pathstroke.h b/examples/widgets/painting/pathstroke/pathstroke.h
index a697101448..d801b05b08 100644
--- a/examples/widgets/painting/pathstroke/pathstroke.h
+++ b/examples/widgets/painting/pathstroke/pathstroke.h
@@ -56,14 +56,14 @@ public:
explicit PathStrokeRenderer(QWidget *parent, bool smallScreen = false);
- void paint(QPainter *);
- void mousePressEvent(QMouseEvent *e);
- void mouseMoveEvent(QMouseEvent *e);
- void mouseReleaseEvent(QMouseEvent *e);
- void timerEvent(QTimerEvent *e);
- bool event(QEvent *e);
-
- QSize sizeHint() const { return QSize(500, 500); }
+ void paint(QPainter *) Q_DECL_OVERRIDE;
+ void mousePressEvent(QMouseEvent *e) Q_DECL_OVERRIDE;
+ void mouseMoveEvent(QMouseEvent *e) Q_DECL_OVERRIDE;
+ void mouseReleaseEvent(QMouseEvent *e) Q_DECL_OVERRIDE;
+ void timerEvent(QTimerEvent *e) Q_DECL_OVERRIDE;
+ bool event(QEvent *e) Q_DECL_OVERRIDE;
+
+ QSize sizeHint() const Q_DECL_OVERRIDE { return QSize(500, 500); }
bool animation() const { return m_timer.isActive(); }
diff --git a/examples/widgets/painting/shared/arthurstyle.h b/examples/widgets/painting/shared/arthurstyle.h
index ede7fe860b..8b78aa14de 100644
--- a/examples/widgets/painting/shared/arthurstyle.h
+++ b/examples/widgets/painting/shared/arthurstyle.h
@@ -54,23 +54,23 @@ public:
void drawHoverRect(QPainter *painter, const QRect &rect) const;
void drawPrimitive(PrimitiveElement element, const QStyleOption *option,
- QPainter *painter, const QWidget *widget = 0) const;
+ QPainter *painter, const QWidget *widget = 0) const Q_DECL_OVERRIDE;
void drawControl(ControlElement element, const QStyleOption *option,
- QPainter *painter, const QWidget *widget) const;
+ QPainter *painter, const QWidget *widget) const Q_DECL_OVERRIDE;
void drawComplexControl(ComplexControl control, const QStyleOptionComplex *option,
- QPainter *painter, const QWidget *widget) const;
+ QPainter *painter, const QWidget *widget) const Q_DECL_OVERRIDE;
QSize sizeFromContents(ContentsType type, const QStyleOption *option,
- const QSize &size, const QWidget *widget) const;
+ const QSize &size, const QWidget *widget) const Q_DECL_OVERRIDE;
- QRect subElementRect(SubElement element, const QStyleOption *option, const QWidget *widget) const;
+ QRect subElementRect(SubElement element, const QStyleOption *option, const QWidget *widget) const Q_DECL_OVERRIDE;
QRect subControlRect(ComplexControl cc, const QStyleOptionComplex *opt,
- SubControl sc, const QWidget *widget) const;
+ SubControl sc, const QWidget *widget) const Q_DECL_OVERRIDE;
- int pixelMetric(PixelMetric metric, const QStyleOption *option, const QWidget *widget) const;
+ int pixelMetric(PixelMetric metric, const QStyleOption *option, const QWidget *widget) const Q_DECL_OVERRIDE;
- void polish(QPalette &palette);
- void polish(QWidget *widget);
- void unpolish(QWidget *widget);
+ void polish(QPalette &palette) Q_DECL_OVERRIDE;
+ void polish(QWidget *widget) Q_DECL_OVERRIDE;
+ void unpolish(QWidget *widget) Q_DECL_OVERRIDE;
};
#endif
diff --git a/examples/widgets/painting/shared/arthurwidgets.h b/examples/widgets/painting/shared/arthurwidgets.h
index 2d96ed63d4..02d0a56656 100644
--- a/examples/widgets/painting/shared/arthurwidgets.h
+++ b/examples/widgets/painting/shared/arthurwidgets.h
@@ -59,9 +59,9 @@ public:
setAttribute(Qt::WA_AcceptTouchEvents);
}
void disableAutoBufferSwap() { setAutoBufferSwap(false); }
- void paintEvent(QPaintEvent *) { parentWidget()->update(); }
+ void paintEvent(QPaintEvent *) Q_DECL_OVERRIDE { parentWidget()->update(); }
protected:
- bool event(QEvent *event)
+ bool event(QEvent *event) Q_DECL_OVERRIDE
{
switch (event->type()) {
case QEvent::TouchBegin:
@@ -117,8 +117,8 @@ signals:
void descriptionEnabledChanged(bool);
protected:
- void paintEvent(QPaintEvent *);
- void resizeEvent(QResizeEvent *);
+ void paintEvent(QPaintEvent *) Q_DECL_OVERRIDE;
+ void resizeEvent(QResizeEvent *) Q_DECL_OVERRIDE;
#if defined(QT_OPENGL_SUPPORT)
GLWidget *glw;
diff --git a/examples/widgets/painting/shared/hoverpoints.h b/examples/widgets/painting/shared/hoverpoints.h
index adc920de30..7fa28c79ed 100644
--- a/examples/widgets/painting/shared/hoverpoints.h
+++ b/examples/widgets/painting/shared/hoverpoints.h
@@ -76,7 +76,7 @@ public:
HoverPoints(QWidget *widget, PointShape shape);
- bool eventFilter(QObject *object, QEvent *event);
+ bool eventFilter(QObject *object, QEvent *event) Q_DECL_OVERRIDE;
void paintPoints();
diff --git a/examples/widgets/painting/transformations/renderarea.h b/examples/widgets/painting/transformations/renderarea.h
index 214c3803d0..fb814d580c 100644
--- a/examples/widgets/painting/transformations/renderarea.h
+++ b/examples/widgets/painting/transformations/renderarea.h
@@ -65,11 +65,11 @@ public:
void setOperations(const QList<Operation> &operations);
void setShape(const QPainterPath &shape);
- QSize minimumSizeHint() const;
- QSize sizeHint() const;
+ QSize minimumSizeHint() const Q_DECL_OVERRIDE;
+ QSize sizeHint() const Q_DECL_OVERRIDE;
protected:
- void paintEvent(QPaintEvent *event);
+ void paintEvent(QPaintEvent *event) Q_DECL_OVERRIDE;
//! [1]
//! [2]