diff options
author | Thiago Macieira <thiago.macieira@intel.com> | 2017-06-12 15:44:17 -0700 |
---|---|---|
committer | Thiago Macieira <thiago.macieira@intel.com> | 2017-06-30 06:22:53 +0000 |
commit | af289aced943418128f84c753017d571ed1e4d4d (patch) | |
tree | ef61ed966c36b39d1de648dd9afe64ebd8e55a5a | |
parent | 0781b64b56ea1116bf5bf214df782772c09f27ca (diff) | |
download | qtsvg-af289aced943418128f84c753017d571ed1e4d4d.tar.gz |
Use QRandomGenerator instead of q?rand
Change-Id: Icd0e0d4b27cb4e5eb892fffd14b5285d43f4afbf
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
-rw-r--r-- | doc/src/examples/bearercloud.qdoc | 6 | ||||
-rw-r--r-- | examples/svg/network/bearercloud/bearercloud.cpp | 5 |
2 files changed, 5 insertions, 6 deletions
diff --git a/doc/src/examples/bearercloud.qdoc b/doc/src/examples/bearercloud.qdoc index eeead0d..a8465e0 100644 --- a/doc/src/examples/bearercloud.qdoc +++ b/doc/src/examples/bearercloud.qdoc @@ -68,9 +68,9 @@ \section1 Setting the Scene - When constructing the scene we first calculate some random offsets using the global qsand() - and qrand() functions. We will use these offsets to scatter the initial position of new Cloud - objects. + When constructing the scene we first calculate some random offsets using \l + QRandomGenerator. We will use these offsets to scatter the initial position + of new Cloud objects. Next we place a text item in the center of the scene to represent the local device and surround it with four concentric circles to help visualize the orbits. diff --git a/examples/svg/network/bearercloud/bearercloud.cpp b/examples/svg/network/bearercloud/bearercloud.cpp index bf2a444..d3f02f2 100644 --- a/examples/svg/network/bearercloud/bearercloud.cpp +++ b/examples/svg/network/bearercloud/bearercloud.cpp @@ -43,8 +43,8 @@ #include <QGraphicsTextItem> #include <QTimer> -#include <QDateTime> #include <QHostInfo> +#include <QRandomGenerator> #include <QDebug> @@ -60,9 +60,8 @@ BearerCloud::BearerCloud(QObject *parent) { setSceneRect(-300, -300, 600, 600); - qsrand(QDateTime::currentDateTime().toTime_t()); - offset[QNetworkConfiguration::Active] = 2 * M_PI * qrand() / RAND_MAX; + offset[QNetworkConfiguration::Active] = QRandomGenerator::bounded(2 * M_PI); offset[QNetworkConfiguration::Discovered] = offset[QNetworkConfiguration::Active] + M_PI / 6; offset[QNetworkConfiguration::Defined] = offset[QNetworkConfiguration::Discovered] - M_PI / 6; offset[QNetworkConfiguration::Undefined] = offset[QNetworkConfiguration::Undefined] + M_PI / 6; |