From 3fede6cb547b783377e833c9b269d4cecfe47e61 Mon Sep 17 00:00:00 2001 From: Christian Ehrlicher Date: Fri, 6 Sep 2019 20:27:33 +0200 Subject: Cleanup QtWidgets (tools) examples Cleanup QtWidgets tools examples: - use member-init (clang-tidy) - fix includes/don't include QtWidgets globally - include own header first - use nullptr (clang-tidy) - avoid c-style casts - use QVector instead QList - use QItemDelegate instead QStyledItemDelegate Change-Id: Ibe9440cdf711e5cc2138c054864edebe1fc95731 Reviewed-by: Paul Wicking --- .../widgets/tools/echoplugin/echowindow/echointerface.h | 3 ++- .../widgets/tools/echoplugin/echowindow/echowindow.cpp | 14 +++++++++++--- examples/widgets/tools/echoplugin/echowindow/main.cpp | 2 +- examples/widgets/tools/echoplugin/plugin/echoplugin.cpp | 2 -- 4 files changed, 14 insertions(+), 7 deletions(-) (limited to 'examples/widgets/tools/echoplugin') diff --git a/examples/widgets/tools/echoplugin/echowindow/echointerface.h b/examples/widgets/tools/echoplugin/echowindow/echointerface.h index 1915330e21..fb07f7fb79 100644 --- a/examples/widgets/tools/echoplugin/echowindow/echointerface.h +++ b/examples/widgets/tools/echoplugin/echowindow/echointerface.h @@ -51,13 +51,14 @@ #ifndef ECHOINTERFACE_H #define ECHOINTERFACE_H +#include #include //! [0] class EchoInterface { public: - virtual ~EchoInterface() {} + virtual ~EchoInterface() = default; virtual QString echo(const QString &message) = 0; }; diff --git a/examples/widgets/tools/echoplugin/echowindow/echowindow.cpp b/examples/widgets/tools/echoplugin/echowindow/echowindow.cpp index 6886a4cd88..dce6bdedc3 100644 --- a/examples/widgets/tools/echoplugin/echowindow/echowindow.cpp +++ b/examples/widgets/tools/echoplugin/echowindow/echowindow.cpp @@ -48,10 +48,17 @@ ** ****************************************************************************/ -#include - #include "echowindow.h" +#include +#include +#include +#include +#include +#include +#include +#include + //! [0] EchoWindow::EchoWindow() { @@ -101,7 +108,7 @@ void EchoWindow::createGUI() //! [3] bool EchoWindow::loadPlugin() { - QDir pluginsDir(qApp->applicationDirPath()); + QDir pluginsDir(QCoreApplication::applicationDirPath()); #if defined(Q_OS_WIN) if (pluginsDir.dirName().toLower() == "debug" || pluginsDir.dirName().toLower() == "release") pluginsDir.cdUp(); @@ -121,6 +128,7 @@ bool EchoWindow::loadPlugin() echoInterface = qobject_cast(plugin); if (echoInterface) return true; + pluginLoader.unload(); } } diff --git a/examples/widgets/tools/echoplugin/echowindow/main.cpp b/examples/widgets/tools/echoplugin/echowindow/main.cpp index 50e3c2763b..d3cf45fcde 100644 --- a/examples/widgets/tools/echoplugin/echowindow/main.cpp +++ b/examples/widgets/tools/echoplugin/echowindow/main.cpp @@ -48,7 +48,7 @@ ** ****************************************************************************/ -#include +#include #include "echowindow.h" #include "echointerface.h" diff --git a/examples/widgets/tools/echoplugin/plugin/echoplugin.cpp b/examples/widgets/tools/echoplugin/plugin/echoplugin.cpp index de6b6a4462..c9dd93aab8 100644 --- a/examples/widgets/tools/echoplugin/plugin/echoplugin.cpp +++ b/examples/widgets/tools/echoplugin/plugin/echoplugin.cpp @@ -48,8 +48,6 @@ ** ****************************************************************************/ -#include - #include "echoplugin.h" //! [0] -- cgit v1.2.3