summaryrefslogtreecommitdiffstats
path: root/examples
diff options
context:
space:
mode:
authorThiago Macieira <thiago.macieira@intel.com>2017-06-12 15:39:51 -0700
committerLars Knoll <lars.knoll@qt.io>2017-07-04 11:45:22 +0000
commit3d279f86ca9b3f8cf8c24016afeb68f58b63a692 (patch)
tree01f29e272bf38ae2376d9b2d15c9eafe84728ed3 /examples
parentb657c2e313a423d98e23a54f2f07b7de4f1f9b36 (diff)
Use QRandomGenerator instead of q?rand
Change-Id: Icd0e0d4b27cb4e5eb892fffd14b5285d43f4afbf Reviewed-by: Lars Knoll <lars.knoll@qt.io>
Diffstat (limited to 'examples')
-rw-r--r--examples/purchasing/qthangman/hangmangame.cpp6
1 files changed, 2 insertions, 4 deletions
diff --git a/examples/purchasing/qthangman/hangmangame.cpp b/examples/purchasing/qthangman/hangmangame.cpp
index a137d10..7358bd1 100644
--- a/examples/purchasing/qthangman/hangmangame.cpp
+++ b/examples/purchasing/qthangman/hangmangame.cpp
@@ -51,8 +51,8 @@
#include "hangmangame.h"
#include <QFile>
#include <QDebug>
-#include <time.h>
#include <QBuffer>
+#include <QRandomGenerator>
#include <QtConcurrent/QtConcurrentRun>
HangmanGame::HangmanGame(QObject *parent)
@@ -60,7 +60,6 @@ HangmanGame::HangmanGame(QObject *parent)
, m_lock(QMutex::Recursive)
, m_vowelsUnlocked(false)
{
- qsrand(::time(0));
connect(this, &HangmanGame::vowelBought, this, &HangmanGame::registerLetterBought);
QtConcurrent::run(this, &HangmanGame::initWordList);
@@ -233,14 +232,13 @@ void HangmanGame::chooseRandomWord()
if (m_wordList.isEmpty())
return;
- m_word = m_wordList.at(qrand() % m_wordList.size());
+ m_word = m_wordList.at(QRandomGenerator::bounded(m_wordList.size()));
emit wordChanged();
}
void HangmanGame::initWordList()
{
QMutexLocker locker(&m_lock);
- qsrand(::time(0) + 1000);
QFile file(":/enable2.txt");
if (file.open(QIODevice::ReadOnly)) {
QByteArray allData = file.readAll();