summaryrefslogtreecommitdiffstats
path: root/examples/declarative/demos/minehunt/minehunt.cpp
diff options
context:
space:
mode:
authorThiago Macieira <thiago.macieira@intel.com>2017-06-12 18:13:17 -0700
committerThiago Macieira <thiago.macieira@intel.com>2017-06-30 06:23:25 +0000
commit8a7b80ebea1fa30d892028e34696890d3321e816 (patch)
tree39c10448ed1c1d0d637b3ca45941ca132afae1e3 /examples/declarative/demos/minehunt/minehunt.cpp
parent9bf0edd9bd46ecb900bcdc3349d14869b87ab7de (diff)
Use QRandomGenerator instead of q?rand
Change-Id: Icd0e0d4b27cb4e5eb892fffd14b5285d43f4afbf Reviewed-by: Lars Knoll <lars.knoll@qt.io>
Diffstat (limited to 'examples/declarative/demos/minehunt/minehunt.cpp')
-rw-r--r--examples/declarative/demos/minehunt/minehunt.cpp7
1 files changed, 3 insertions, 4 deletions
diff --git a/examples/declarative/demos/minehunt/minehunt.cpp b/examples/declarative/demos/minehunt/minehunt.cpp
index d9237eee..2ef4a9be 100644
--- a/examples/declarative/demos/minehunt/minehunt.cpp
+++ b/examples/declarative/demos/minehunt/minehunt.cpp
@@ -32,7 +32,7 @@
****************************************************************************/
#include <stdlib.h>
-#include <QTime>
+#include <QRandomGenerator>
#include <QTimer>
#include "minehunt.h"
@@ -63,7 +63,6 @@ MinehuntGame::MinehuntGame()
: numCols(9), numRows(9), playing(true), won(false)
{
setObjectName("mainObject");
- srand(QTime(0,0,0).secsTo(QTime::currentTime()));
//initialize array
for(int ii = 0; ii < numRows * numCols; ++ii) {
@@ -83,8 +82,8 @@ void MinehuntGame::setBoard()
int mines = nMines;
remaining = numRows*numCols-mines;
while ( mines ) {
- int col = int((double(rand()) / double(RAND_MAX)) * numCols);
- int row = int((double(rand()) / double(RAND_MAX)) * numRows);
+ int col = QRandomGenerator::bounded(numCols);
+ int row = QRandomGenerator::bounded(numRows);
TileData* t = tile( row, col );