aboutsummaryrefslogtreecommitdiffstats
path: root/examples/quick/scenegraph/sgengine/window.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'examples/quick/scenegraph/sgengine/window.cpp')
-rw-r--r--examples/quick/scenegraph/sgengine/window.cpp11
1 files changed, 6 insertions, 5 deletions
diff --git a/examples/quick/scenegraph/sgengine/window.cpp b/examples/quick/scenegraph/sgengine/window.cpp
index 96b730ebfc..6f22510a81 100644
--- a/examples/quick/scenegraph/sgengine/window.cpp
+++ b/examples/quick/scenegraph/sgengine/window.cpp
@@ -58,6 +58,7 @@
#include <QScreen>
#include <QVariantAnimation>
#include <QOpenGLFunctions>
+#include <QRandomGenerator>
class Item {
public:
@@ -71,9 +72,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::global()->generateDouble() * 400 + 800;
+ rotAnimation.setStartValue(QRandomGenerator::global()->generateDouble() * 720 - 180);
+ rotAnimation.setEndValue(QRandomGenerator::global()->generateDouble() * 720 - 180);
rotAnimation.setDuration(duration);
rotAnimation.start();
@@ -181,8 +182,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::global()->generateDouble() * (height() - tex->textureSize().height()));
+ QPointF toPos(width(), QRandomGenerator::global()->generateDouble() * height() * 1.5 - height() * 0.25);
m_items.append(QSharedPointer<Item>::create(m_sgRootNode.data(), tex, fromPos, toPos));
}
update();