diff --git a/examples/designer/calculatorbuilder/calculatorform.h b/examples/designer/calculatorbuilder/calculatorform.h index 03024c664203aaada97df1138cf04dc6b1f96da1..1a1f00c8c7acb0df5c3ec88d55eb8591d0ece764 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 f8c3b04e29000ee6071bdabda5a58d37fe5032e2..a521b0c73c780becf248748ec5619c9da4368ed1 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 8bb95180cf7530afdaa0a9a60839ae6d607c446f..d73d3972baefd3562e5e2975ac261c10b3a3a54a 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 cdb74d33bee0d596fa62b179201d2b39ce18d83a..ed83fc3aa1b8853f0aa126b1f51df258eca04510 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 5011116f70b21e58ccf744ba12338ea99ca59db7..09c228e87abffac9e1372d88c70d87a8dd2729fd 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 56a02aebde4ed458bbfac1c649fd785c21cea358..bb26f40eb480c4d14b8ceb5b0fe29367b91b4c73 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 bb94d046c4089cdb6325df24a0ca58a369a12933..d29043ecf1ed1ba12d0be8845cf0aaa4d89b3798 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 a2f3cbc5f353f2bf862d77c434ddf7a9ce736199..a5dace5243d641d496f2c6d54925c31b1ff2226a 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 73401fc38c8d1ec61ff58df70b3334245f53dcc7..713d24e5ebec87578f600f53f728fa8cf4ca44bf 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 cb758ce8399b1d6c748b4eb45ac3f8aa2e6e2919..cf2d854b368c737346c4943bb3bf3f04088bf0f2 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 803121d067f1388bbe97f4c69a14b789710a52f8..a3d75d311d090ac0ac506d08eb3ebfbd19ceacac 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 c10ab339c99411a2ca0472e4ed7d7bd607b965a0..d9b7c022b5318a927f14b45bc18d67645f81818a 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 23655050da7ea359105acd1ac374e54b45873d64..c6370a2cb1fadc1fc52787515a5bf79e177b6b1a 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 6d922a9e982443b4e565b337cf4cdd9948c11b5e..1904f9c977b9dba07c5a4495de8aaa253b123006 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 6948a5d4eac715fb1abb371b5b3de1e63c77d782..e82edaa1123c7fcdb648273639d4de9ab9317341 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 1272b4286b0332a06296f6ddf41015f105eedcdf..724720ad53a1202dd8d1828245620a5672098424 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 1c1ce7a3882caf2a2268f59678a68b717a4081b7..9aa8b565092727aaef07cfab3960431e450b6ee6 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 df13ed60bdd444349849dcf5b0b3d4fad06fe6b3..75d1f625c26adf7d27b4fac23cf0f01ce78468f1 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 bcd5b63b3fe1541e65107b8cbe0c59f95c251b14..a57ded625fbe658f7b088cfd484563e592828228 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 158d01af50eb105a3403d93469970e7888293f70..3663942874ba2a6a10b25371cd39af00d7f02c89 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 faf057b098ae8a975f329348ee66dd10617a4c62..e2d54a7e4ff5151f1c498e1cdd0c43f33f07ed91 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 61e6f3075d3047ba62b710a9b2c20fdb5424630f..8cd059c561a5fd2a02d185fed5c6d02db6b16f59 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 d1487735bd4dc956047aa8fd8c7dc0bb87301466..0af0b1dd02687131dd15402597d994eaefe9ede8 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]