diff options
Diffstat (limited to 'examples/widgets/graphicsview/collidingmice')
-rw-r--r-- | examples/widgets/graphicsview/collidingmice/main.cpp | 5 | ||||
-rw-r--r-- | examples/widgets/graphicsview/collidingmice/mouse.cpp | 9 | ||||
-rw-r--r-- | examples/widgets/graphicsview/collidingmice/mouse.h | 6 |
3 files changed, 9 insertions, 11 deletions
diff --git a/examples/widgets/graphicsview/collidingmice/main.cpp b/examples/widgets/graphicsview/collidingmice/main.cpp index dfb20815b9..ef6d6cca64 100644 --- a/examples/widgets/graphicsview/collidingmice/main.cpp +++ b/examples/widgets/graphicsview/collidingmice/main.cpp @@ -48,13 +48,12 @@ ** ****************************************************************************/ +#include <QtMath> #include <QtWidgets> -#include <math.h> - #include "mouse.h" -static const int MouseCount = 7; +static constexpr int MouseCount = 7; //! [0] int main(int argc, char **argv) diff --git a/examples/widgets/graphicsview/collidingmice/mouse.cpp b/examples/widgets/graphicsview/collidingmice/mouse.cpp index a8fcc05d76..556e58d19b 100644 --- a/examples/widgets/graphicsview/collidingmice/mouse.cpp +++ b/examples/widgets/graphicsview/collidingmice/mouse.cpp @@ -54,10 +54,10 @@ #include <QPainter> #include <QRandomGenerator> #include <QStyleOption> -#include <qmath.h> +#include <QtMath> -const qreal Pi = M_PI; -const qreal TwoPi = 2 * M_PI; +constexpr qreal Pi = M_PI; +constexpr qreal TwoPi = 2 * M_PI; static qreal normalizeAngle(qreal angle) { @@ -70,8 +70,7 @@ static qreal normalizeAngle(qreal angle) //! [0] Mouse::Mouse() - : angle(0), speed(0), mouseEyeDirection(0), - color(QRandomGenerator::global()->bounded(256), QRandomGenerator::global()->bounded(256), QRandomGenerator::global()->bounded(256)) + : color(QRandomGenerator::global()->bounded(256), QRandomGenerator::global()->bounded(256), QRandomGenerator::global()->bounded(256)) { setRotation(QRandomGenerator::global()->bounded(360 * 16)); } diff --git a/examples/widgets/graphicsview/collidingmice/mouse.h b/examples/widgets/graphicsview/collidingmice/mouse.h index bd9e592242..4b165fced6 100644 --- a/examples/widgets/graphicsview/collidingmice/mouse.h +++ b/examples/widgets/graphicsview/collidingmice/mouse.h @@ -68,9 +68,9 @@ protected: void advance(int step) override; private: - qreal angle; - qreal speed; - qreal mouseEyeDirection; + qreal angle = 0; + qreal speed = 0; + qreal mouseEyeDirection = 0; QColor color; }; //! [0] |