diff options
author | Christian Ehrlicher <ch.ehrlicher@gmx.de> | 2019-09-06 22:38:45 +0200 |
---|---|---|
committer | Christian Ehrlicher <ch.ehrlicher@gmx.de> | 2019-09-17 23:05:23 +0200 |
commit | cb54c16584cf3be746a1a536c1e37cb3022a2f1b (patch) | |
tree | 712a4ee8d6383918233654e1deeefb3e91371941 /examples/widgets/widgets/windowflags | |
parent | 7db335a77e9efcfc8e0d4c1bd0834100403ec3b1 (diff) |
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 <Friedemann.Kleint@qt.io>
Diffstat (limited to 'examples/widgets/widgets/windowflags')
-rw-r--r-- | examples/widgets/widgets/windowflags/controllerwindow.cpp | 30 | ||||
-rw-r--r-- | examples/widgets/widgets/windowflags/previewwindow.cpp | 21 |
2 files changed, 28 insertions, 23 deletions
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 <QtWidgets> - #include "controllerwindow.h" +#include <QCheckBox> +#include <QCoreApplication> +#include <QGroupBox> +#include <QHBoxLayout> +#include <QPushButton> +#include <QRadioButton> + //! [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 <QtWidgets> +#include <QPushButton> +#include <QTextEdit> +#include <QVBoxLayout> //! [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"; |