diff options
23 files changed, 49 insertions, 64 deletions
diff --git a/examples/designer/calculatorbuilder/calculatorform.h b/examples/designer/calculatorbuilder/calculatorform.h index 03024c664..1a1f00c8c 100644 --- a/examples/designer/calculatorbuilder/calculatorform.h +++ b/examples/designer/calculatorbuilder/calculatorform.h @@ -64,7 +64,7 @@ class CalculatorForm : public QWidget Q_OBJECT public: - CalculatorForm(QWidget *parent = 0); + explicit CalculatorForm(QWidget *parent = nullptr); private slots: void on_inputSpinBox1_valueChanged(int value); diff --git a/examples/designer/calculatorform/calculatorform.h b/examples/designer/calculatorform/calculatorform.h index f8c3b04e2..a521b0c73 100644 --- a/examples/designer/calculatorform/calculatorform.h +++ b/examples/designer/calculatorform/calculatorform.h @@ -61,7 +61,7 @@ class CalculatorForm : public QWidget Q_OBJECT public: - CalculatorForm(QWidget *parent = 0); + explicit CalculatorForm(QWidget *parent = nullptr); private slots: void on_inputSpinBox1_valueChanged(int value); diff --git a/examples/designer/containerextension/multipagewidget.cpp b/examples/designer/containerextension/multipagewidget.cpp index 8bb95180c..d73d3972b 100644 --- a/examples/designer/containerextension/multipagewidget.cpp +++ b/examples/designer/containerextension/multipagewidget.cpp @@ -59,11 +59,9 @@ MultiPageWidget::MultiPageWidget(QWidget *parent) , stackWidget(new QStackedWidget) , comboBox(new QComboBox) { - typedef void (QComboBox::*ComboBoxActivatedIntSignal)(int); + comboBox->setObjectName(QStringLiteral("__qt__passive_comboBox")); - comboBox->setObjectName("__qt__passive_comboBox"); - - connect(comboBox, static_cast<ComboBoxActivatedIntSignal>(&QComboBox::activated), + connect(comboBox, QOverload<int>::of(&QComboBox::activated), this, &MultiPageWidget::setCurrentIndex); QVBoxLayout *layout = new QVBoxLayout(this); diff --git a/examples/designer/containerextension/multipagewidget.h b/examples/designer/containerextension/multipagewidget.h index cdb74d33b..ed83fc3aa 100644 --- a/examples/designer/containerextension/multipagewidget.h +++ b/examples/designer/containerextension/multipagewidget.h @@ -66,7 +66,7 @@ class MultiPageWidget : public QWidget Q_PROPERTY(QString pageTitle READ pageTitle WRITE setPageTitle STORED false) public: - explicit MultiPageWidget(QWidget *parent = 0); + explicit MultiPageWidget(QWidget *parent = nullptr); QSize sizeHint() const override; diff --git a/examples/designer/containerextension/multipagewidgetextensionfactory.cpp b/examples/designer/containerextension/multipagewidgetextensionfactory.cpp index 5011116f7..09c228e87 100644 --- a/examples/designer/containerextension/multipagewidgetextensionfactory.cpp +++ b/examples/designer/containerextension/multipagewidgetextensionfactory.cpp @@ -65,10 +65,8 @@ QObject *MultiPageWidgetExtensionFactory::createExtension(QObject *object, { MultiPageWidget *widget = qobject_cast<MultiPageWidget*>(object); - if (widget && (iid == Q_TYPEID(QDesignerContainerExtension))) { + if (widget && (iid == Q_TYPEID(QDesignerContainerExtension))) return new MultiPageWidgetContainerExtension(widget, parent); - } else { - return 0; - } + return nullptr; } //! [1] diff --git a/examples/designer/containerextension/multipagewidgetextensionfactory.h b/examples/designer/containerextension/multipagewidgetextensionfactory.h index 56a02aebd..bb26f40eb 100644 --- a/examples/designer/containerextension/multipagewidgetextensionfactory.h +++ b/examples/designer/containerextension/multipagewidgetextensionfactory.h @@ -63,7 +63,7 @@ class MultiPageWidgetExtensionFactory: public QExtensionFactory Q_OBJECT public: - explicit MultiPageWidgetExtensionFactory(QExtensionManager *parent = 0); + explicit MultiPageWidgetExtensionFactory(QExtensionManager *parent = nullptr); protected: QObject *createExtension(QObject *object, const QString &iid, QObject *parent) const override; diff --git a/examples/designer/containerextension/multipagewidgetplugin.cpp b/examples/designer/containerextension/multipagewidgetplugin.cpp index bb94d046c..d29043ecf 100644 --- a/examples/designer/containerextension/multipagewidgetplugin.cpp +++ b/examples/designer/containerextension/multipagewidgetplugin.cpp @@ -65,7 +65,6 @@ //! [0] MultiPageWidgetPlugin::MultiPageWidgetPlugin(QObject *parent) : QObject(parent) - , initialized(false) { } diff --git a/examples/designer/containerextension/multipagewidgetplugin.h b/examples/designer/containerextension/multipagewidgetplugin.h index a2f3cbc5f..a5dace524 100644 --- a/examples/designer/containerextension/multipagewidgetplugin.h +++ b/examples/designer/containerextension/multipagewidgetplugin.h @@ -67,7 +67,7 @@ class MultiPageWidgetPlugin: public QObject, public QDesignerCustomWidgetInterfa //! [1] Q_INTERFACES(QDesignerCustomWidgetInterface) public: - explicit MultiPageWidgetPlugin(QObject *parent = 0); + explicit MultiPageWidgetPlugin(QObject *parent = nullptr); QString name() const override; QString group() const override; @@ -86,7 +86,7 @@ private slots: void pageTitleChanged(const QString &title); private: - bool initialized; + bool initialized = false; }; #endif diff --git a/examples/designer/customwidgetplugin/analogclock.cpp b/examples/designer/customwidgetplugin/analogclock.cpp index 73401fc38..713d24e5e 100644 --- a/examples/designer/customwidgetplugin/analogclock.cpp +++ b/examples/designer/customwidgetplugin/analogclock.cpp @@ -58,10 +58,8 @@ AnalogClock::AnalogClock(QWidget *parent) : QWidget(parent) { - typedef void (QWidget::*WidgetUpdateSlot)(); - QTimer *timer = new QTimer(this); - connect(timer, &QTimer::timeout, this, static_cast<WidgetUpdateSlot>(&QWidget::update)); + connect(timer, &QTimer::timeout, this, QOverload<>::of(&QWidget::update)); timer->start(1000); setWindowTitle(tr("Analog Clock")); diff --git a/examples/designer/customwidgetplugin/analogclock.h b/examples/designer/customwidgetplugin/analogclock.h index cb758ce83..cf2d854b3 100644 --- a/examples/designer/customwidgetplugin/analogclock.h +++ b/examples/designer/customwidgetplugin/analogclock.h @@ -59,7 +59,7 @@ class QDESIGNER_WIDGET_EXPORT AnalogClock : public QWidget Q_OBJECT public: - explicit AnalogClock(QWidget *parent = 0); + explicit AnalogClock(QWidget *parent = nullptr); protected: void paintEvent(QPaintEvent *event) override; diff --git a/examples/designer/customwidgetplugin/customwidgetplugin.cpp b/examples/designer/customwidgetplugin/customwidgetplugin.cpp index 803121d06..a3d75d311 100644 --- a/examples/designer/customwidgetplugin/customwidgetplugin.cpp +++ b/examples/designer/customwidgetplugin/customwidgetplugin.cpp @@ -56,7 +56,6 @@ //! [0] AnalogClockPlugin::AnalogClockPlugin(QObject *parent) : QObject(parent) - , initialized(false) { } //! [0] @@ -88,14 +87,14 @@ QWidget *AnalogClockPlugin::createWidget(QWidget *parent) //! [4] QString AnalogClockPlugin::name() const { - return "AnalogClock"; + return QStringLiteral("AnalogClock"); } //! [4] //! [5] QString AnalogClockPlugin::group() const { - return "Display Widgets [Examples]"; + return QStringLiteral("Display Widgets [Examples]"); } //! [5] @@ -109,14 +108,14 @@ QIcon AnalogClockPlugin::icon() const //! [7] QString AnalogClockPlugin::toolTip() const { - return ""; + return QString(); } //! [7] //! [8] QString AnalogClockPlugin::whatsThis() const { - return ""; + return QString(); } //! [8] @@ -156,6 +155,6 @@ QString AnalogClockPlugin::domXml() const //! [12] QString AnalogClockPlugin::includeFile() const { - return "analogclock.h"; + return QStringLiteral("analogclock.h"); } //! [12] diff --git a/examples/designer/customwidgetplugin/customwidgetplugin.h b/examples/designer/customwidgetplugin/customwidgetplugin.h index c10ab339c..d9b7c022b 100644 --- a/examples/designer/customwidgetplugin/customwidgetplugin.h +++ b/examples/designer/customwidgetplugin/customwidgetplugin.h @@ -60,7 +60,7 @@ class AnalogClockPlugin : public QObject, public QDesignerCustomWidgetInterface Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QDesignerCustomWidgetInterface") Q_INTERFACES(QDesignerCustomWidgetInterface) public: - explicit AnalogClockPlugin(QObject *parent = 0); + explicit AnalogClockPlugin(QObject *parent = nullptr); bool isContainer() const override; bool isInitialized() const override; @@ -75,7 +75,7 @@ public: void initialize(QDesignerFormEditorInterface *core) override; private: - bool initialized; + bool initialized = false; }; //! [0] diff --git a/examples/designer/taskmenuextension/tictactoe.cpp b/examples/designer/taskmenuextension/tictactoe.cpp index 23655050d..c6370a2cb 100644 --- a/examples/designer/taskmenuextension/tictactoe.cpp +++ b/examples/designer/taskmenuextension/tictactoe.cpp @@ -53,9 +53,10 @@ #include <QMouseEvent> #include <QPainter> +static inline QString defaultState() { return QStringLiteral("---------"); } + TicTacToe::TicTacToe(QWidget *parent) : QWidget(parent) - , turnNumber(0) { } @@ -72,7 +73,7 @@ QSize TicTacToe::sizeHint() const void TicTacToe::setState(const QString &newState) { turnNumber = 0; - myState = "---------"; + myState = defaultState(); int position = 0; while (position < 9 && position < newState.length()) { QChar mark = newState.at(position); @@ -92,7 +93,7 @@ QString TicTacToe::state() const void TicTacToe::clearBoard() { - myState = "---------"; + myState = defaultState(); turnNumber = 0; update(); } diff --git a/examples/designer/taskmenuextension/tictactoe.h b/examples/designer/taskmenuextension/tictactoe.h index 6d922a9e9..1904f9c97 100644 --- a/examples/designer/taskmenuextension/tictactoe.h +++ b/examples/designer/taskmenuextension/tictactoe.h @@ -65,7 +65,7 @@ class TicTacToe : public QWidget Q_PROPERTY(QString state READ state WRITE setState) public: - explicit TicTacToe(QWidget *parent = 0); + explicit TicTacToe(QWidget *parent = nullptr); QSize minimumSizeHint() const override; QSize sizeHint() const override; @@ -78,14 +78,14 @@ protected: void paintEvent(QPaintEvent *event) override; private: - enum { Empty = '-', Cross = 'X', Nought = 'O' }; + enum : char { Empty = '-', Cross = 'X', Nought = 'O' }; QRect cellRect(int row, int col) const; int cellWidth() const { return width() / 3; } int cellHeight() const { return height() / 3; } QString myState; - int turnNumber; + int turnNumber = 0; }; //! [0] diff --git a/examples/designer/taskmenuextension/tictactoedialog.h b/examples/designer/taskmenuextension/tictactoedialog.h index 6948a5d4e..e82edaa11 100644 --- a/examples/designer/taskmenuextension/tictactoedialog.h +++ b/examples/designer/taskmenuextension/tictactoedialog.h @@ -64,7 +64,7 @@ class TicTacToeDialog : public QDialog Q_OBJECT public: - explicit TicTacToeDialog(TicTacToe *plugin = 0, QWidget *parent = 0); + explicit TicTacToeDialog(TicTacToe *plugin = nullptr, QWidget *parent = nullptr); QSize sizeHint() const override; diff --git a/examples/designer/taskmenuextension/tictactoeplugin.cpp b/examples/designer/taskmenuextension/tictactoeplugin.cpp index 1272b4286..724720ad5 100644 --- a/examples/designer/taskmenuextension/tictactoeplugin.cpp +++ b/examples/designer/taskmenuextension/tictactoeplugin.cpp @@ -59,33 +59,32 @@ //! [0] TicTacToePlugin::TicTacToePlugin(QObject *parent) : QObject(parent) - , initialized(false) { } QString TicTacToePlugin::name() const { - return "TicTacToe"; + return QStringLiteral("TicTacToe"); } QString TicTacToePlugin::group() const { - return "Display Widgets [Examples]"; + return QStringLiteral("Display Widgets [Examples]"); } QString TicTacToePlugin::toolTip() const { - return ""; + return QString(); } QString TicTacToePlugin::whatsThis() const { - return ""; + return QString(); } QString TicTacToePlugin::includeFile() const { - return "tictactoe.h"; + return QStringLiteral("tictactoe.h"); } QIcon TicTacToePlugin::icon() const @@ -101,7 +100,7 @@ bool TicTacToePlugin::isContainer() const QWidget *TicTacToePlugin::createWidget(QWidget *parent) { TicTacToe *ticTacToe = new TicTacToe(parent); - ticTacToe->setState("-X-XO----"); + ticTacToe->setState(QStringLiteral("-X-XO----")); return ticTacToe; } diff --git a/examples/designer/taskmenuextension/tictactoeplugin.h b/examples/designer/taskmenuextension/tictactoeplugin.h index 1c1ce7a38..9aa8b5650 100644 --- a/examples/designer/taskmenuextension/tictactoeplugin.h +++ b/examples/designer/taskmenuextension/tictactoeplugin.h @@ -68,7 +68,7 @@ class TicTacToePlugin : public QObject, public QDesignerCustomWidgetInterface Q_INTERFACES(QDesignerCustomWidgetInterface) public: - TicTacToePlugin(QObject *parent = 0); + explicit TicTacToePlugin(QObject *parent = nullptr); QString name() const override; QString group() const override; @@ -83,7 +83,7 @@ public: QString domXml() const override; private: - bool initialized; + bool initialized = false; }; #endif diff --git a/examples/designer/taskmenuextension/tictactoetaskmenu.cpp b/examples/designer/taskmenuextension/tictactoetaskmenu.cpp index df13ed60b..75d1f625c 100644 --- a/examples/designer/taskmenuextension/tictactoetaskmenu.cpp +++ b/examples/designer/taskmenuextension/tictactoetaskmenu.cpp @@ -83,9 +83,7 @@ QAction *TicTacToeTaskMenu::preferredEditAction() const //! [3] QList<QAction *> TicTacToeTaskMenu::taskActions() const { - QList<QAction *> list; - list.append(editStateAction); - return list; + return QList<QAction *>{editStateAction}; } //! [3] @@ -102,11 +100,11 @@ QObject *TicTacToeTaskMenuFactory::createExtension(QObject *object, QObject *parent) const { if (iid != Q_TYPEID(QDesignerTaskMenuExtension)) - return 0; + return nullptr; if (TicTacToe *tic = qobject_cast<TicTacToe*>(object)) return new TicTacToeTaskMenu(tic, parent); - return 0; + return nullptr; } //! [5] diff --git a/examples/designer/taskmenuextension/tictactoetaskmenu.h b/examples/designer/taskmenuextension/tictactoetaskmenu.h index bcd5b63b3..a57ded625 100644 --- a/examples/designer/taskmenuextension/tictactoetaskmenu.h +++ b/examples/designer/taskmenuextension/tictactoetaskmenu.h @@ -87,7 +87,7 @@ class TicTacToeTaskMenuFactory : public QExtensionFactory Q_OBJECT public: - explicit TicTacToeTaskMenuFactory(QExtensionManager *parent = 0); + explicit TicTacToeTaskMenuFactory(QExtensionManager *parent = nullptr); protected: QObject *createExtension(QObject *object, const QString &iid, QObject *parent) const override; diff --git a/examples/designer/worldtimeclockplugin/worldtimeclock.cpp b/examples/designer/worldtimeclockplugin/worldtimeclock.cpp index 158d01af5..366394287 100644 --- a/examples/designer/worldtimeclockplugin/worldtimeclock.cpp +++ b/examples/designer/worldtimeclockplugin/worldtimeclock.cpp @@ -56,13 +56,9 @@ WorldTimeClock::WorldTimeClock(QWidget *parent) : QWidget(parent) - , timeZoneOffset(0) - { - typedef void (QWidget::*WidgetUpdateSlot)(); - QTimer *timer = new QTimer(this); - connect(timer, &QTimer::timeout, this, static_cast<WidgetUpdateSlot>(&QWidget::update)); + connect(timer, &QTimer::timeout, this, QOverload<>::of(&QWidget::update)); timer->start(1000); setWindowTitle(tr("World Time Clock")); diff --git a/examples/designer/worldtimeclockplugin/worldtimeclock.h b/examples/designer/worldtimeclockplugin/worldtimeclock.h index faf057b09..e2d54a7e4 100644 --- a/examples/designer/worldtimeclockplugin/worldtimeclock.h +++ b/examples/designer/worldtimeclockplugin/worldtimeclock.h @@ -62,7 +62,7 @@ class QDESIGNER_WIDGET_EXPORT WorldTimeClock : public QWidget //! [0] public: - explicit WorldTimeClock(QWidget *parent = 0); + explicit WorldTimeClock(QWidget *parent = nullptr); public slots: void setTimeZone(int hourOffset); @@ -74,7 +74,7 @@ protected: void paintEvent(QPaintEvent *event) override; private: - int timeZoneOffset; + int timeZoneOffset = 0; //! [2] }; //! [1] //! [2] diff --git a/examples/designer/worldtimeclockplugin/worldtimeclockplugin.cpp b/examples/designer/worldtimeclockplugin/worldtimeclockplugin.cpp index 61e6f3075..8cd059c56 100644 --- a/examples/designer/worldtimeclockplugin/worldtimeclockplugin.cpp +++ b/examples/designer/worldtimeclockplugin/worldtimeclockplugin.cpp @@ -55,7 +55,6 @@ WorldTimeClockPlugin::WorldTimeClockPlugin(QObject *parent) : QObject(parent) - , initialized(false) { } @@ -79,12 +78,12 @@ QWidget *WorldTimeClockPlugin::createWidget(QWidget *parent) QString WorldTimeClockPlugin::name() const { - return "WorldTimeClock"; + return QStringLiteral("WorldTimeClock"); } QString WorldTimeClockPlugin::group() const { - return "Display Widgets [Examples]"; + return QStringLiteral("Display Widgets [Examples]"); } QIcon WorldTimeClockPlugin::icon() const @@ -94,12 +93,12 @@ QIcon WorldTimeClockPlugin::icon() const QString WorldTimeClockPlugin::toolTip() const { - return ""; + return QString(); } QString WorldTimeClockPlugin::whatsThis() const { - return ""; + return QString(); } bool WorldTimeClockPlugin::isContainer() const @@ -125,5 +124,5 @@ QString WorldTimeClockPlugin::domXml() const QString WorldTimeClockPlugin::includeFile() const { - return "worldtimeclock.h"; + return QStringLiteral("worldtimeclock.h"); } diff --git a/examples/designer/worldtimeclockplugin/worldtimeclockplugin.h b/examples/designer/worldtimeclockplugin/worldtimeclockplugin.h index d1487735b..0af0b1dd0 100644 --- a/examples/designer/worldtimeclockplugin/worldtimeclockplugin.h +++ b/examples/designer/worldtimeclockplugin/worldtimeclockplugin.h @@ -64,7 +64,7 @@ class WorldTimeClockPlugin : public QObject, Q_INTERFACES(QDesignerCustomWidgetInterface) public: - explicit WorldTimeClockPlugin(QObject *parent = 0); + explicit WorldTimeClockPlugin(QObject *parent = nullptr); bool isContainer() const override; bool isInitialized() const override; @@ -79,7 +79,7 @@ public: void initialize(QDesignerFormEditorInterface *core) override; private: - bool initialized; + bool initialized = false; }; //! [0] |