diff options
author | Olivier Goffart <ogoffart@woboq.com> | 2014-07-14 09:13:02 +0200 |
---|---|---|
committer | Olivier Goffart <ogoffart@woboq.com> | 2014-07-15 08:44:44 +0200 |
commit | 3b0c2b7c1b3ccdfe6867884a7e210bfc63e10f84 (patch) | |
tree | 4c75a4fa9f023c4bfc6746a4412922a8efe3b017 /examples/widgets/animation/stickman | |
parent | 6d87e3ed40173eac8c275d5926266359d53c74c7 (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/animation/stickman')
-rw-r--r-- | examples/widgets/animation/stickman/graphicsview.h | 4 | ||||
-rw-r--r-- | examples/widgets/animation/stickman/lifecycle.cpp | 4 | ||||
-rw-r--r-- | examples/widgets/animation/stickman/node.h | 12 | ||||
-rw-r--r-- | examples/widgets/animation/stickman/rectbutton.h | 6 | ||||
-rw-r--r-- | examples/widgets/animation/stickman/stickman.h | 6 |
5 files changed, 16 insertions, 16 deletions
diff --git a/examples/widgets/animation/stickman/graphicsview.h b/examples/widgets/animation/stickman/graphicsview.h index 60abb6448f..cdccbbfbd3 100644 --- a/examples/widgets/animation/stickman/graphicsview.h +++ b/examples/widgets/animation/stickman/graphicsview.h @@ -51,8 +51,8 @@ public: GraphicsView(QWidget *parent = 0); protected: - virtual void resizeEvent(QResizeEvent *event); - void keyPressEvent(QKeyEvent *); + virtual void resizeEvent(QResizeEvent *event) Q_DECL_OVERRIDE; + void keyPressEvent(QKeyEvent *) Q_DECL_OVERRIDE; signals: void keyPressed(int key); diff --git a/examples/widgets/animation/stickman/lifecycle.cpp b/examples/widgets/animation/stickman/lifecycle.cpp index 09ca45e55b..7b089b5459 100644 --- a/examples/widgets/animation/stickman/lifecycle.cpp +++ b/examples/widgets/animation/stickman/lifecycle.cpp @@ -60,7 +60,7 @@ public: setTargetState(target); } - virtual bool eventTest(QEvent *e) + virtual bool eventTest(QEvent *e) Q_DECL_OVERRIDE { if (QSignalTransition::eventTest(e)) { QVariant key = static_cast<QStateMachine::SignalEvent*>(e)->arguments().at(0); @@ -85,7 +85,7 @@ public: startTimer(1000); } - virtual bool eventTest(QEvent *e) + virtual bool eventTest(QEvent *e) Q_DECL_OVERRIDE { return QEventTransition::eventTest(e) && ((qrand() % 50) == 0); } diff --git a/examples/widgets/animation/stickman/node.h b/examples/widgets/animation/stickman/node.h index 9c7cc8d75a..6da83d5474 100644 --- a/examples/widgets/animation/stickman/node.h +++ b/examples/widgets/animation/stickman/node.h @@ -50,18 +50,18 @@ public: explicit Node(const QPointF &pos, QGraphicsItem *parent = 0); ~Node(); - QRectF boundingRect() const; - void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget); + QRectF boundingRect() const Q_DECL_OVERRIDE; + void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) Q_DECL_OVERRIDE; signals: void positionChanged(); protected: - QVariant itemChange(GraphicsItemChange change, const QVariant &value); + QVariant itemChange(GraphicsItemChange change, const QVariant &value) Q_DECL_OVERRIDE; - void mousePressEvent(QGraphicsSceneMouseEvent *); - void mouseMoveEvent(QGraphicsSceneMouseEvent *); - void mouseReleaseEvent(QGraphicsSceneMouseEvent *); + void mousePressEvent(QGraphicsSceneMouseEvent *) Q_DECL_OVERRIDE; + void mouseMoveEvent(QGraphicsSceneMouseEvent *) Q_DECL_OVERRIDE; + void mouseReleaseEvent(QGraphicsSceneMouseEvent *) Q_DECL_OVERRIDE; private: bool m_dragging; diff --git a/examples/widgets/animation/stickman/rectbutton.h b/examples/widgets/animation/stickman/rectbutton.h index 16c70fddd4..1cc9be2f97 100644 --- a/examples/widgets/animation/stickman/rectbutton.h +++ b/examples/widgets/animation/stickman/rectbutton.h @@ -50,13 +50,13 @@ public: RectButton(QString buttonText); ~RectButton(); - virtual QRectF boundingRect() const; - virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget); + virtual QRectF boundingRect() const Q_DECL_OVERRIDE; + virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) Q_DECL_OVERRIDE; protected: QString m_ButtonText; - virtual void mousePressEvent (QGraphicsSceneMouseEvent *event); + virtual void mousePressEvent (QGraphicsSceneMouseEvent *event) Q_DECL_OVERRIDE; signals: void clicked(); diff --git a/examples/widgets/animation/stickman/stickman.h b/examples/widgets/animation/stickman/stickman.h index 08928a48a6..d8538efc52 100644 --- a/examples/widgets/animation/stickman/stickman.h +++ b/examples/widgets/animation/stickman/stickman.h @@ -59,8 +59,8 @@ public: StickMan(); ~StickMan(); - virtual QRectF boundingRect() const; - virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget); + virtual QRectF boundingRect() const Q_DECL_OVERRIDE; + virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) Q_DECL_OVERRIDE; int nodeCount() const; Node *node(int idx) const; @@ -82,7 +82,7 @@ public slots: void childPositionChanged(); protected: - void timerEvent(QTimerEvent *e); + void timerEvent(QTimerEvent *e) Q_DECL_OVERRIDE; private: |