diff options
author | Christian Ehrlicher <ch.ehrlicher@gmx.de> | 2018-12-02 14:17:21 +0100 |
---|---|---|
committer | Christian Ehrlicher <ch.ehrlicher@gmx.de> | 2018-12-13 16:57:05 +0000 |
commit | 588bd92228efa7ed3a92929e0eb90c22be189e04 (patch) | |
tree | b92c71975554764161cddeacac9e14824f7a4c5f /examples/widgets | |
parent | fd83e03e7f634cda97ab793d67deb0e0b2377562 (diff) |
Cleanup Widgets examples - parent ctor
Cleanup the Widgets examples - add missing parent parameter
Change-Id: I5cd7aa333dbb8e6e4b7b9e05c085120733da83ec
Reviewed-by: Samuel Gaist <samuel.gaist@idiap.ch>
Reviewed-by: Konstantin Shegunov <kshegunov@gmail.com>
Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
Reviewed-by: Paul Wicking <paul.wicking@qt.io>
Diffstat (limited to 'examples/widgets')
25 files changed, 40 insertions, 30 deletions
diff --git a/examples/widgets/widgets/calendarwidget/window.cpp b/examples/widgets/widgets/calendarwidget/window.cpp index c3a0e1e3f7..a1c1746786 100644 --- a/examples/widgets/widgets/calendarwidget/window.cpp +++ b/examples/widgets/widgets/calendarwidget/window.cpp @@ -53,7 +53,8 @@ #include "window.h" //! [0] -Window::Window() +Window::Window(QWidget *parent) + : QWidget(parent) { createPreviewGroupBox(); createGeneralOptionsGroupBox(); diff --git a/examples/widgets/widgets/calendarwidget/window.h b/examples/widgets/widgets/calendarwidget/window.h index fa01fc4db6..83ea494fc2 100644 --- a/examples/widgets/widgets/calendarwidget/window.h +++ b/examples/widgets/widgets/calendarwidget/window.h @@ -70,7 +70,7 @@ class Window : public QWidget Q_OBJECT public: - Window(); + Window(QWidget *parent = nullptr); private slots: void localeChanged(int index); diff --git a/examples/widgets/widgets/charactermap/mainwindow.cpp b/examples/widgets/widgets/charactermap/mainwindow.cpp index d3ac55483c..76bd8f7799 100644 --- a/examples/widgets/widgets/charactermap/mainwindow.cpp +++ b/examples/widgets/widgets/charactermap/mainwindow.cpp @@ -57,7 +57,8 @@ Q_DECLARE_METATYPE(QFontComboBox::FontFilter) -MainWindow::MainWindow() +MainWindow::MainWindow(QWidget *parent) + : QMainWindow(parent) { QMenu *fileMenu = menuBar()->addMenu(tr("File")); fileMenu->addAction(tr("Quit"), this, &QWidget::close); diff --git a/examples/widgets/widgets/charactermap/mainwindow.h b/examples/widgets/widgets/charactermap/mainwindow.h index eac16b35fa..79fe9f9cc8 100644 --- a/examples/widgets/widgets/charactermap/mainwindow.h +++ b/examples/widgets/widgets/charactermap/mainwindow.h @@ -70,7 +70,7 @@ class MainWindow : public QMainWindow Q_OBJECT public: - MainWindow(); + MainWindow(QWidget *parent = nullptr); public slots: void filterChanged(int); diff --git a/examples/widgets/widgets/icons/mainwindow.cpp b/examples/widgets/widgets/icons/mainwindow.cpp index f704b8306f..904245494c 100644 --- a/examples/widgets/widgets/icons/mainwindow.cpp +++ b/examples/widgets/widgets/icons/mainwindow.cpp @@ -60,7 +60,8 @@ enum { OtherSize = QStyle::PM_CustomBase }; //! [40] //! [0] -MainWindow::MainWindow() +MainWindow::MainWindow(QWidget *parent) + : QMainWindow(parent) { QWidget *centralWidget = new QWidget(this); setCentralWidget(centralWidget); diff --git a/examples/widgets/widgets/icons/mainwindow.h b/examples/widgets/widgets/icons/mainwindow.h index e3888e5fb1..1949bd235c 100644 --- a/examples/widgets/widgets/icons/mainwindow.h +++ b/examples/widgets/widgets/icons/mainwindow.h @@ -74,7 +74,7 @@ class MainWindow : public QMainWindow Q_OBJECT public: - MainWindow(); + MainWindow(QWidget *parent = nullptr); void loadImages(const QStringList &fileNames); diff --git a/examples/widgets/widgets/imageviewer/imageviewer.cpp b/examples/widgets/widgets/imageviewer/imageviewer.cpp index 327abf7e43..b1346d9ccb 100644 --- a/examples/widgets/widgets/imageviewer/imageviewer.cpp +++ b/examples/widgets/widgets/imageviewer/imageviewer.cpp @@ -59,10 +59,9 @@ #include "imageviewer.h" //! [0] -ImageViewer::ImageViewer() - : imageLabel(new QLabel) - , scrollArea(new QScrollArea) - , scaleFactor(1) +ImageViewer::ImageViewer(QWidget *parent) + : QMainWindow(parent), imageLabel(new QLabel), + scrollArea(new QScrollArea), scaleFactor(1) { imageLabel->setBackgroundRole(QPalette::Base); imageLabel->setSizePolicy(QSizePolicy::Ignored, QSizePolicy::Ignored); diff --git a/examples/widgets/widgets/imageviewer/imageviewer.h b/examples/widgets/widgets/imageviewer/imageviewer.h index f4a62cafe9..7e53105b33 100644 --- a/examples/widgets/widgets/imageviewer/imageviewer.h +++ b/examples/widgets/widgets/imageviewer/imageviewer.h @@ -71,7 +71,7 @@ class ImageViewer : public QMainWindow Q_OBJECT public: - ImageViewer(); + ImageViewer(QWidget *parent = nullptr); bool loadFile(const QString &); private slots: diff --git a/examples/widgets/widgets/lineedits/window.cpp b/examples/widgets/widgets/lineedits/window.cpp index ffb1edc5ce..47324589b7 100644 --- a/examples/widgets/widgets/lineedits/window.cpp +++ b/examples/widgets/widgets/lineedits/window.cpp @@ -53,7 +53,8 @@ #include "window.h" //! [0] -Window::Window() +Window::Window(QWidget *parent) + : QWidget(parent) { QGroupBox *echoGroup = new QGroupBox(tr("Echo")); diff --git a/examples/widgets/widgets/lineedits/window.h b/examples/widgets/widgets/lineedits/window.h index 2070b3b84c..3231588f4f 100644 --- a/examples/widgets/widgets/lineedits/window.h +++ b/examples/widgets/widgets/lineedits/window.h @@ -64,7 +64,7 @@ class Window : public QWidget Q_OBJECT public: - Window(); + Window(QWidget *parent = nullptr); public slots: void echoChanged(int); diff --git a/examples/widgets/widgets/mousebuttons/buttontester.h b/examples/widgets/widgets/mousebuttons/buttontester.h index d99dcceb18..231733bd44 100644 --- a/examples/widgets/widgets/mousebuttons/buttontester.h +++ b/examples/widgets/widgets/mousebuttons/buttontester.h @@ -59,13 +59,14 @@ class ButtonTester : public QTextEdit { Q_OBJECT - +public: + using QTextEdit::QTextEdit; protected: void mousePressEvent(QMouseEvent *event) override; void mouseReleaseEvent(QMouseEvent *event) override; void mouseDoubleClickEvent(QMouseEvent *event) override; #if QT_CONFIG(wheelevent) - void wheelEvent(QWheelEvent * event) override; + void wheelEvent(QWheelEvent *event) override; #endif int buttonByNumber(const Qt::MouseButton button); QString enumNameFromValue(const Qt::MouseButton button); diff --git a/examples/widgets/widgets/scribble/mainwindow.cpp b/examples/widgets/widgets/scribble/mainwindow.cpp index d54e5ce0f9..b8d01d505c 100644 --- a/examples/widgets/widgets/scribble/mainwindow.cpp +++ b/examples/widgets/widgets/scribble/mainwindow.cpp @@ -54,9 +54,9 @@ #include "scribblearea.h" //! [0] -MainWindow::MainWindow() +MainWindow::MainWindow(QWidget *parent) + : QMainWindow(parent), scribbleArea(new ScribbleArea(this)) { - scribbleArea = new ScribbleArea; setCentralWidget(scribbleArea); createActions(); diff --git a/examples/widgets/widgets/scribble/mainwindow.h b/examples/widgets/widgets/scribble/mainwindow.h index 9e0ddaff71..e57ff065ac 100644 --- a/examples/widgets/widgets/scribble/mainwindow.h +++ b/examples/widgets/widgets/scribble/mainwindow.h @@ -62,7 +62,7 @@ class MainWindow : public QMainWindow Q_OBJECT public: - MainWindow(); + MainWindow(QWidget *parent = nullptr); protected: void closeEvent(QCloseEvent *event) override; diff --git a/examples/widgets/widgets/sliders/window.cpp b/examples/widgets/widgets/sliders/window.cpp index 16b60dde49..16467e71be 100644 --- a/examples/widgets/widgets/sliders/window.cpp +++ b/examples/widgets/widgets/sliders/window.cpp @@ -54,7 +54,8 @@ #include "window.h" //! [0] -Window::Window() +Window::Window(QWidget *parent) + : QWidget(parent) { horizontalSliders = new SlidersGroup(Qt::Horizontal, tr("Horizontal")); verticalSliders = new SlidersGroup(Qt::Vertical, tr("Vertical")); diff --git a/examples/widgets/widgets/sliders/window.h b/examples/widgets/widgets/sliders/window.h index 9c4c14fa37..4894781ac2 100644 --- a/examples/widgets/widgets/sliders/window.h +++ b/examples/widgets/widgets/sliders/window.h @@ -69,7 +69,7 @@ class Window : public QWidget Q_OBJECT public: - Window(); + Window(QWidget *parent = nullptr); private: void createControls(const QString &title); diff --git a/examples/widgets/widgets/spinboxes/window.cpp b/examples/widgets/widgets/spinboxes/window.cpp index 54604e35aa..eb660faace 100644 --- a/examples/widgets/widgets/spinboxes/window.cpp +++ b/examples/widgets/widgets/spinboxes/window.cpp @@ -53,7 +53,8 @@ #include "window.h" //! [0] -Window::Window() +Window::Window(QWidget *parent) + : QWidget(parent) { createSpinBoxes(); createDateTimeEdits(); diff --git a/examples/widgets/widgets/spinboxes/window.h b/examples/widgets/widgets/spinboxes/window.h index 97e9ac1083..138773a5aa 100644 --- a/examples/widgets/widgets/spinboxes/window.h +++ b/examples/widgets/widgets/spinboxes/window.h @@ -67,7 +67,7 @@ class Window : public QWidget Q_OBJECT public: - Window(); + Window(QWidget *parent = nullptr); public slots: void changePrecision(int decimals); diff --git a/examples/widgets/widgets/stylesheet/mainwindow.cpp b/examples/widgets/widgets/stylesheet/mainwindow.cpp index 9acd90658a..eb4b3a2424 100644 --- a/examples/widgets/widgets/stylesheet/mainwindow.cpp +++ b/examples/widgets/widgets/stylesheet/mainwindow.cpp @@ -53,7 +53,8 @@ #include "mainwindow.h" #include "stylesheeteditor.h" -MainWindow::MainWindow() +MainWindow::MainWindow(QWidget *parent) + : QMainWindow(parent) { ui.setupUi(this); diff --git a/examples/widgets/widgets/stylesheet/mainwindow.h b/examples/widgets/widgets/stylesheet/mainwindow.h index 46d3ecbb93..8af4c01da0 100644 --- a/examples/widgets/widgets/stylesheet/mainwindow.h +++ b/examples/widgets/widgets/stylesheet/mainwindow.h @@ -62,7 +62,7 @@ class MainWindow : public QMainWindow Q_OBJECT public: - MainWindow(); + MainWindow(QWidget *parent = nullptr); private slots: void on_editStyleAction_triggered(); diff --git a/examples/widgets/widgets/tetrix/tetrixwindow.cpp b/examples/widgets/widgets/tetrix/tetrixwindow.cpp index 7e951aceb8..970a38c1dc 100644 --- a/examples/widgets/widgets/tetrix/tetrixwindow.cpp +++ b/examples/widgets/widgets/tetrix/tetrixwindow.cpp @@ -54,7 +54,8 @@ #include "tetrixwindow.h" //! [0] -TetrixWindow::TetrixWindow() +TetrixWindow::TetrixWindow(QWidget *parent) + : QWidget(parent) { board = new TetrixBoard; //! [0] diff --git a/examples/widgets/widgets/tetrix/tetrixwindow.h b/examples/widgets/widgets/tetrix/tetrixwindow.h index a21cef2ecf..02226ffe1c 100644 --- a/examples/widgets/widgets/tetrix/tetrixwindow.h +++ b/examples/widgets/widgets/tetrix/tetrixwindow.h @@ -67,7 +67,7 @@ class TetrixWindow : public QWidget Q_OBJECT public: - TetrixWindow(); + TetrixWindow(QWidget *parent = nullptr); private: QLabel *createLabel(const QString &text); diff --git a/examples/widgets/widgets/tooltips/sortingbox.cpp b/examples/widgets/widgets/tooltips/sortingbox.cpp index 4769a30c64..766815e8e9 100644 --- a/examples/widgets/widgets/tooltips/sortingbox.cpp +++ b/examples/widgets/widgets/tooltips/sortingbox.cpp @@ -55,7 +55,8 @@ #include "sortingbox.h" //! [0] -SortingBox::SortingBox() +SortingBox::SortingBox(QWidget *parent) + : QWidget(parent) { //! [0] //! [1] setMouseTracking(true); diff --git a/examples/widgets/widgets/tooltips/sortingbox.h b/examples/widgets/widgets/tooltips/sortingbox.h index 2ac27614a5..12bdeff1f6 100644 --- a/examples/widgets/widgets/tooltips/sortingbox.h +++ b/examples/widgets/widgets/tooltips/sortingbox.h @@ -67,7 +67,7 @@ class SortingBox : public QWidget Q_OBJECT public: - SortingBox(); + SortingBox(QWidget *parent = nullptr); protected: bool event(QEvent *event) override; diff --git a/examples/widgets/widgets/windowflags/controllerwindow.cpp b/examples/widgets/widgets/windowflags/controllerwindow.cpp index 78323810ed..c19f23c513 100644 --- a/examples/widgets/widgets/windowflags/controllerwindow.cpp +++ b/examples/widgets/widgets/windowflags/controllerwindow.cpp @@ -53,7 +53,8 @@ #include "controllerwindow.h" //! [0] -ControllerWindow::ControllerWindow() +ControllerWindow::ControllerWindow(QWidget *parent) + : QWidget(parent) { previewWindow = new PreviewWindow(this); diff --git a/examples/widgets/widgets/windowflags/controllerwindow.h b/examples/widgets/widgets/windowflags/controllerwindow.h index cfb88ed20f..43ec67e27f 100644 --- a/examples/widgets/widgets/windowflags/controllerwindow.h +++ b/examples/widgets/widgets/windowflags/controllerwindow.h @@ -69,7 +69,7 @@ class ControllerWindow : public QWidget Q_OBJECT public: - ControllerWindow(); + ControllerWindow(QWidget *parent = nullptr); private slots: void updatePreview(); |