summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-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();