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/gui/analogclock/main.cpp | 4 ++-- examples/gui/openglwindow/main.cpp | 4 ++-- examples/gui/openglwindow/openglwindow.h | 4 ++-- examples/gui/rasterwindow/rasterwindow.h | 6 +++--- 4 files changed, 9 insertions(+), 9 deletions(-) (limited to 'examples/gui') diff --git a/examples/gui/analogclock/main.cpp b/examples/gui/analogclock/main.cpp index 1e10fcd07b..d51f440dff 100644 --- a/examples/gui/analogclock/main.cpp +++ b/examples/gui/analogclock/main.cpp @@ -49,8 +49,8 @@ public: AnalogClockWindow(); protected: - void timerEvent(QTimerEvent *); - void render(QPainter *p); + void timerEvent(QTimerEvent *) Q_DECL_OVERRIDE; + void render(QPainter *p) Q_DECL_OVERRIDE; private: int m_timerId; diff --git a/examples/gui/openglwindow/main.cpp b/examples/gui/openglwindow/main.cpp index aa1c6d7fa1..0b0a0e19f0 100644 --- a/examples/gui/openglwindow/main.cpp +++ b/examples/gui/openglwindow/main.cpp @@ -53,8 +53,8 @@ class TriangleWindow : public OpenGLWindow public: TriangleWindow(); - void initialize(); - void render(); + void initialize() Q_DECL_OVERRIDE; + void render() Q_DECL_OVERRIDE; private: GLuint loadShader(GLenum type, const char *source); diff --git a/examples/gui/openglwindow/openglwindow.h b/examples/gui/openglwindow/openglwindow.h index f6b53e3b33..cee888250b 100644 --- a/examples/gui/openglwindow/openglwindow.h +++ b/examples/gui/openglwindow/openglwindow.h @@ -67,9 +67,9 @@ public slots: void renderNow(); protected: - bool event(QEvent *event); + bool event(QEvent *event) Q_DECL_OVERRIDE; - void exposeEvent(QExposeEvent *event); + void exposeEvent(QExposeEvent *event) Q_DECL_OVERRIDE; private: bool m_update_pending; diff --git a/examples/gui/rasterwindow/rasterwindow.h b/examples/gui/rasterwindow/rasterwindow.h index 8dc3993849..bca73c19e7 100644 --- a/examples/gui/rasterwindow/rasterwindow.h +++ b/examples/gui/rasterwindow/rasterwindow.h @@ -57,10 +57,10 @@ public slots: void renderNow(); protected: - bool event(QEvent *event); + bool event(QEvent *event) Q_DECL_OVERRIDE; - void resizeEvent(QResizeEvent *event); - void exposeEvent(QExposeEvent *event); + void resizeEvent(QResizeEvent *event) Q_DECL_OVERRIDE; + void exposeEvent(QExposeEvent *event) Q_DECL_OVERRIDE; private: QBackingStore *m_backingStore; -- cgit v1.2.3