summaryrefslogtreecommitdiffstats
path: root/examples/declarative
diff options
context:
space:
mode:
authorThiago Macieira <thiago.macieira@intel.com>2017-10-24 20:48:50 -0700
committerThiago Macieira <thiago.macieira@intel.com>2017-10-26 16:32:07 +0000
commitb2476dcd53f0dea1e9eb38df5add3a771d64c4a1 (patch)
treee05afff48b503fe24408dd20f0cba356417f5bb3 /examples/declarative
parent4f7b6037720b21b8150f8495b7318d139d447541 (diff)
Revert "Use QRandomGenerator instead of q?rand"
This reverts commit 8a7b80ebea1fa30d892028e34696890d3321e816. Let's just leave qtquick1 with the old qrand API. Change-Id: Icaa86fc7b54d4b368c0efffd14f0b39b77f17d30 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
Diffstat (limited to 'examples/declarative')
-rw-r--r--examples/declarative/demos/minehunt/minehunt.cpp7
1 files changed, 4 insertions, 3 deletions
diff --git a/examples/declarative/demos/minehunt/minehunt.cpp b/examples/declarative/demos/minehunt/minehunt.cpp
index 2ef4a9be..d9237eee 100644
--- a/examples/declarative/demos/minehunt/minehunt.cpp
+++ b/examples/declarative/demos/minehunt/minehunt.cpp
@@ -32,7 +32,7 @@
****************************************************************************/
#include <stdlib.h>
-#include <QRandomGenerator>
+#include <QTime>
#include <QTimer>
#include "minehunt.h"
@@ -63,6 +63,7 @@ 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) {
@@ -82,8 +83,8 @@ void MinehuntGame::setBoard()
int mines = nMines;
remaining = numRows*numCols-mines;
while ( mines ) {
- int col = QRandomGenerator::bounded(numCols);
- int row = QRandomGenerator::bounded(numRows);
+ int col = int((double(rand()) / double(RAND_MAX)) * numCols);
+ int row = int((double(rand()) / double(RAND_MAX)) * numRows);
TileData* t = tile( row, col );