From cb54c16584cf3be746a1a536c1e37cb3022a2f1b Mon Sep 17 00:00:00 2001 From: Christian Ehrlicher Date: Fri, 6 Sep 2019 22:38:45 +0200 Subject: Cleanup QtWidgets (widgets) examples Cleanup QtWidgets widgets 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 Change-Id: Ib56bb507eb2ef885f1ddc664050d3c7af92adb70 Reviewed-by: Friedemann Kleint --- .../widgets/windowflags/controllerwindow.cpp | 30 ++++++++++++---------- .../widgets/widgets/windowflags/previewwindow.cpp | 21 +++++++-------- 2 files changed, 28 insertions(+), 23 deletions(-) (limited to 'examples/widgets/widgets/windowflags') diff --git a/examples/widgets/widgets/windowflags/controllerwindow.cpp b/examples/widgets/widgets/windowflags/controllerwindow.cpp index e2abad89f4..0e9a916988 100644 --- a/examples/widgets/widgets/windowflags/controllerwindow.cpp +++ b/examples/widgets/widgets/windowflags/controllerwindow.cpp @@ -48,10 +48,15 @@ ** ****************************************************************************/ -#include - #include "controllerwindow.h" +#include +#include +#include +#include +#include +#include + //! [0] ControllerWindow::ControllerWindow(QWidget *parent) : QWidget(parent) @@ -63,7 +68,7 @@ ControllerWindow::ControllerWindow(QWidget *parent) quitButton = new QPushButton(tr("&Quit")); connect(quitButton, &QPushButton::clicked, - qApp, &QApplication::quit); + qApp, &QCoreApplication::quit); QHBoxLayout *bottomLayout = new QHBoxLayout; bottomLayout->addStretch(); @@ -83,26 +88,25 @@ ControllerWindow::ControllerWindow(QWidget *parent) //! [1] void ControllerWindow::updatePreview() { - Qt::WindowFlags flags = 0; + Qt::WindowFlags flags; - if (windowRadioButton->isChecked()) { + if (windowRadioButton->isChecked()) flags = Qt::Window; - } else if (dialogRadioButton->isChecked()) { + else if (dialogRadioButton->isChecked()) flags = Qt::Dialog; - } else if (sheetRadioButton->isChecked()) { + else if (sheetRadioButton->isChecked()) flags = Qt::Sheet; - } else if (drawerRadioButton->isChecked()) { + else if (drawerRadioButton->isChecked()) flags = Qt::Drawer; - } else if (popupRadioButton->isChecked()) { + else if (popupRadioButton->isChecked()) flags = Qt::Popup; - } else if (toolRadioButton->isChecked()) { + else if (toolRadioButton->isChecked()) flags = Qt::Tool; - } else if (toolTipRadioButton->isChecked()) { + else if (toolTipRadioButton->isChecked()) flags = Qt::ToolTip; - } else if (splashScreenRadioButton->isChecked()) { + else if (splashScreenRadioButton->isChecked()) flags = Qt::SplashScreen; //! [1] //! [2] - } //! [2] //! [3] if (msWindowsFixedSizeDialogCheckBox->isChecked()) diff --git a/examples/widgets/widgets/windowflags/previewwindow.cpp b/examples/widgets/widgets/windowflags/previewwindow.cpp index 8773dccb05..d7ebed7b3c 100644 --- a/examples/widgets/widgets/windowflags/previewwindow.cpp +++ b/examples/widgets/widgets/windowflags/previewwindow.cpp @@ -50,7 +50,9 @@ #include "previewwindow.h" -#include +#include +#include +#include //! [0] PreviewWindow::PreviewWindow(QWidget *parent) @@ -81,23 +83,22 @@ void PreviewWindow::setWindowFlags(Qt::WindowFlags flags) QString text; Qt::WindowFlags type = (flags & Qt::WindowType_Mask); - if (type == Qt::Window) { + if (type == Qt::Window) text = "Qt::Window"; - } else if (type == Qt::Dialog) { + else if (type == Qt::Dialog) text = "Qt::Dialog"; - } else if (type == Qt::Sheet) { + else if (type == Qt::Sheet) text = "Qt::Sheet"; - } else if (type == Qt::Drawer) { + else if (type == Qt::Drawer) text = "Qt::Drawer"; - } else if (type == Qt::Popup) { + else if (type == Qt::Popup) text = "Qt::Popup"; - } else if (type == Qt::Tool) { + else if (type == Qt::Tool) text = "Qt::Tool"; - } else if (type == Qt::ToolTip) { + else if (type == Qt::ToolTip) text = "Qt::ToolTip"; - } else if (type == Qt::SplashScreen) { + else if (type == Qt::SplashScreen) text = "Qt::SplashScreen"; - } if (flags & Qt::MSWindowsFixedSizeDialogHint) text += "\n| Qt::MSWindowsFixedSizeDialogHint"; -- cgit v1.2.3