diff options
Diffstat (limited to 'examples/widgets/widgets/tooltips')
-rw-r--r-- | examples/widgets/widgets/tooltips/shapeitem.cpp | 2 | ||||
-rw-r--r-- | examples/widgets/widgets/tooltips/sortingbox.cpp | 15 | ||||
-rw-r--r-- | examples/widgets/widgets/tooltips/sortingbox.h | 6 |
3 files changed, 10 insertions, 13 deletions
diff --git a/examples/widgets/widgets/tooltips/shapeitem.cpp b/examples/widgets/widgets/tooltips/shapeitem.cpp index 70c1cc03dc..68cc744b84 100644 --- a/examples/widgets/widgets/tooltips/shapeitem.cpp +++ b/examples/widgets/widgets/tooltips/shapeitem.cpp @@ -48,8 +48,6 @@ ** ****************************************************************************/ -#include <QtWidgets> - #include "shapeitem.h" //! [0] diff --git a/examples/widgets/widgets/tooltips/sortingbox.cpp b/examples/widgets/widgets/tooltips/sortingbox.cpp index 4769a30c64..685eaa7d1d 100644 --- a/examples/widgets/widgets/tooltips/sortingbox.cpp +++ b/examples/widgets/widgets/tooltips/sortingbox.cpp @@ -48,14 +48,13 @@ ** ****************************************************************************/ -#include <QtWidgets> - -#include <stdlib.h> - #include "sortingbox.h" +#include <QtWidgets> + //! [0] -SortingBox::SortingBox() +SortingBox::SortingBox(QWidget *parent) + : QWidget(parent) { //! [0] //! [1] setMouseTracking(true); @@ -63,7 +62,7 @@ SortingBox::SortingBox() setBackgroundRole(QPalette::Base); //! [2] - itemInMotion = 0; + itemInMotion = nullptr; //! [3] newCircleButton = createToolButton(tr("New Circle"), @@ -139,7 +138,7 @@ void SortingBox::paintEvent(QPaintEvent * /* event */) { QPainter painter(this); painter.setRenderHint(QPainter::Antialiasing); - foreach (ShapeItem shapeItem, shapeItems) { + for (const ShapeItem &shapeItem : qAsConst(shapeItems)) { //! [8] //! [9] painter.translate(shapeItem.position()); //! [9] //! [10] @@ -178,7 +177,7 @@ void SortingBox::mouseReleaseEvent(QMouseEvent *event) { if (event->button() == Qt::LeftButton && itemInMotion) { moveItemTo(event->pos()); - itemInMotion = 0; + itemInMotion = nullptr; } } //! [13] diff --git a/examples/widgets/widgets/tooltips/sortingbox.h b/examples/widgets/widgets/tooltips/sortingbox.h index 2ac27614a5..3d0cecea2b 100644 --- a/examples/widgets/widgets/tooltips/sortingbox.h +++ b/examples/widgets/widgets/tooltips/sortingbox.h @@ -51,10 +51,10 @@ #ifndef SORTINGBOX_H #define SORTINGBOX_H -#include <QWidget> - #include "shapeitem.h" +#include <QWidget> + QT_BEGIN_NAMESPACE class QAction; class QPoint; @@ -67,7 +67,7 @@ class SortingBox : public QWidget Q_OBJECT public: - SortingBox(); + SortingBox(QWidget *parent = nullptr); protected: bool event(QEvent *event) override; |