From 2b7b24a0e039a18db8ab23475fbab44718f758a2 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Mon, 12 Jun 2017 15:28:13 -0700 Subject: Use QRandomGenerator instead of q?rand Change-Id: Icd0e0d4b27cb4e5eb892fffd14b5285d43f4afbf Reviewed-by: Simon Hausmann --- examples/quick/scenegraph/sgengine/window.cpp | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'examples/quick/scenegraph/sgengine') diff --git a/examples/quick/scenegraph/sgengine/window.cpp b/examples/quick/scenegraph/sgengine/window.cpp index a73d9bf755..0e5c738ce5 100644 --- a/examples/quick/scenegraph/sgengine/window.cpp +++ b/examples/quick/scenegraph/sgengine/window.cpp @@ -48,6 +48,7 @@ #include #include #include +#include class Item { public: @@ -61,9 +62,9 @@ public: transformNode->appendChildNode(textureNode); parentNode->appendChildNode(transformNode); - int duration = qrand() / float(RAND_MAX) * 400 + 800; - rotAnimation.setStartValue(qrand() / float(RAND_MAX) * 720 - 180); - rotAnimation.setEndValue(qrand() / float(RAND_MAX) * 720 - 180); + int duration = QRandomGenerator::getReal() * 400 + 800; + rotAnimation.setStartValue(QRandomGenerator::getReal() * 720 - 180); + rotAnimation.setEndValue(QRandomGenerator::getReal() * 720 - 180); rotAnimation.setDuration(duration); rotAnimation.start(); @@ -171,8 +172,8 @@ void Window::addItems() QSGTexture *textures[] = { m_smileTexture.data(), m_qtTexture.data() }; for (int i = 0; i < 50; ++i) { QSGTexture *tex = textures[i%2]; - QPointF fromPos(-tex->textureSize().width(), qrand() / float(RAND_MAX) * (height() - tex->textureSize().height())); - QPointF toPos(width(), qrand() / float(RAND_MAX) * height() * 1.5 - height() * 0.25); + QPointF fromPos(-tex->textureSize().width(), QRandomGenerator::getReal() * (height() - tex->textureSize().height())); + QPointF toPos(width(), QRandomGenerator::getReal() * height() * 1.5 - height() * 0.25); m_items.append(QSharedPointer::create(m_sgRootNode.data(), tex, fromPos, toPos)); } update(); -- cgit v1.2.3