From 3b0c2b7c1b3ccdfe6867884a7e210bfc63e10f84 Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Mon, 14 Jul 2014 09:13:02 +0200 Subject: Examples: Add Q_DECL_OVERRIDE to overridden functions MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- examples/touch/fingerpaint/mainwindow.h | 2 +- examples/touch/fingerpaint/scribblearea.h | 6 +++--- examples/touch/knobs/knob.h | 2 +- examples/touch/pinchzoom/graphicsview.h | 2 +- examples/touch/pinchzoom/mouse.h | 8 ++++---- 5 files changed, 10 insertions(+), 10 deletions(-) (limited to 'examples/touch') diff --git a/examples/touch/fingerpaint/mainwindow.h b/examples/touch/fingerpaint/mainwindow.h index 4d97f7e13f..997ea064f2 100644 --- a/examples/touch/fingerpaint/mainwindow.h +++ b/examples/touch/fingerpaint/mainwindow.h @@ -55,7 +55,7 @@ public: MainWindow(); protected: - void closeEvent(QCloseEvent *event); + void closeEvent(QCloseEvent *event) Q_DECL_OVERRIDE; private slots: void open(); diff --git a/examples/touch/fingerpaint/scribblearea.h b/examples/touch/fingerpaint/scribblearea.h index e6c8e8d155..2019bfc58f 100644 --- a/examples/touch/fingerpaint/scribblearea.h +++ b/examples/touch/fingerpaint/scribblearea.h @@ -64,9 +64,9 @@ public slots: void print(); protected: - void paintEvent(QPaintEvent *event); - void resizeEvent(QResizeEvent *event); - bool event(QEvent *event); + void paintEvent(QPaintEvent *event) Q_DECL_OVERRIDE; + void resizeEvent(QResizeEvent *event) Q_DECL_OVERRIDE; + bool event(QEvent *event) Q_DECL_OVERRIDE; private: void resizeImage(QImage *image, const QSize &newSize); diff --git a/examples/touch/knobs/knob.h b/examples/touch/knobs/knob.h index 645e2174a8..a3315a9b1d 100644 --- a/examples/touch/knobs/knob.h +++ b/examples/touch/knobs/knob.h @@ -48,7 +48,7 @@ class Knob : public QGraphicsEllipseItem public: Knob(); - bool sceneEvent(QEvent *event); + bool sceneEvent(QEvent *event) Q_DECL_OVERRIDE; }; #endif // KNOB_H diff --git a/examples/touch/pinchzoom/graphicsview.h b/examples/touch/pinchzoom/graphicsview.h index 5553f4b6d6..63728acaf6 100644 --- a/examples/touch/pinchzoom/graphicsview.h +++ b/examples/touch/pinchzoom/graphicsview.h @@ -48,7 +48,7 @@ class GraphicsView : public QGraphicsView public: GraphicsView(QGraphicsScene *scene = 0, QWidget *parent = 0); - bool viewportEvent(QEvent *event); + bool viewportEvent(QEvent *event) Q_DECL_OVERRIDE; private: qreal totalScaleFactor; diff --git a/examples/touch/pinchzoom/mouse.h b/examples/touch/pinchzoom/mouse.h index 22b571b692..9a705e5062 100644 --- a/examples/touch/pinchzoom/mouse.h +++ b/examples/touch/pinchzoom/mouse.h @@ -51,13 +51,13 @@ class Mouse : public QGraphicsObject public: Mouse(); - QRectF boundingRect() const; - QPainterPath shape() const; + QRectF boundingRect() const Q_DECL_OVERRIDE; + QPainterPath shape() const Q_DECL_OVERRIDE; void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, - QWidget *widget); + QWidget *widget) Q_DECL_OVERRIDE; protected: - void timerEvent(QTimerEvent *event); + void timerEvent(QTimerEvent *event) Q_DECL_OVERRIDE; private: qreal angle; -- cgit v1.2.3