summaryrefslogtreecommitdiffstats
path: root/examples
diff options
context:
space:
mode:
Diffstat (limited to 'examples')
-rw-r--r--examples/embedded/flickable/main.cpp2
-rw-r--r--examples/network/fortuneserver/server.cpp2
-rw-r--r--examples/network/threadedfortuneserver/fortuneserver.cpp2
-rw-r--r--examples/network/torrent/torrentclient.cpp16
-rw-r--r--examples/widgets/mainwindows/mainwindow/toolbar.cpp2
5 files changed, 12 insertions, 12 deletions
diff --git a/examples/embedded/flickable/main.cpp b/examples/embedded/flickable/main.cpp
index 973154331d..d3b314fcd0 100644
--- a/examples/embedded/flickable/main.cpp
+++ b/examples/embedded/flickable/main.cpp
@@ -72,7 +72,7 @@ static QStringList colorPairs(int max)
// randomize it
colors.clear();
while (combinedColors.count()) {
- int i = QRandomGenerator::global()->bounded(combinedColors.count());
+ int i = QRandomGenerator::global()->bounded(int(combinedColors.count()));
colors << combinedColors[i];
combinedColors.removeAt(i);
if (colors.count() == max)
diff --git a/examples/network/fortuneserver/server.cpp b/examples/network/fortuneserver/server.cpp
index c91b6a5c0c..95aadb60c9 100644
--- a/examples/network/fortuneserver/server.cpp
+++ b/examples/network/fortuneserver/server.cpp
@@ -145,7 +145,7 @@ void Server::sendFortune()
QDataStream out(&block, QIODevice::WriteOnly);
out.setVersion(QDataStream::Qt_5_10);
- out << fortunes[QRandomGenerator::global()->bounded(fortunes.size())];
+ out << fortunes[QRandomGenerator::global()->bounded(int(fortunes.size()))];
//! [4] //! [7]
QTcpSocket *clientConnection = tcpServer->nextPendingConnection();
diff --git a/examples/network/threadedfortuneserver/fortuneserver.cpp b/examples/network/threadedfortuneserver/fortuneserver.cpp
index 73d7e22531..a93bbc7058 100644
--- a/examples/network/threadedfortuneserver/fortuneserver.cpp
+++ b/examples/network/threadedfortuneserver/fortuneserver.cpp
@@ -72,7 +72,7 @@ FortuneServer::FortuneServer(QObject *parent)
//! [1]
void FortuneServer::incomingConnection(qintptr socketDescriptor)
{
- QString fortune = fortunes.at(QRandomGenerator::global()->bounded(fortunes.size()));
+ QString fortune = fortunes.at(QRandomGenerator::global()->bounded(int(fortunes.size())));
FortuneThread *thread = new FortuneThread(socketDescriptor, fortune, this);
connect(thread, &FortuneThread::finished, thread, &FortuneThread::deleteLater);
thread->start();
diff --git a/examples/network/torrent/torrentclient.cpp b/examples/network/torrent/torrentclient.cpp
index 035cf665bb..6ae5339d28 100644
--- a/examples/network/torrent/torrentclient.cpp
+++ b/examples/network/torrent/torrentclient.cpp
@@ -700,7 +700,7 @@ void TorrentClient::connectToPeers()
d->connections << client;
// Pick a random peer from the list of weighed peers.
- TorrentPeer *peer = weighedPeers.takeAt(QRandomGenerator::global()->bounded(weighedPeers.size()));
+ TorrentPeer *peer = weighedPeers.takeAt(QRandomGenerator::global()->bounded(int(weighedPeers.size())));
weighedPeers.removeAll(peer);
peer->connectStart = QDateTime::currentSecsSinceEpoch();
peer->lastVisited = peer->connectStart;
@@ -1130,7 +1130,7 @@ void TorrentClient::scheduleUploads()
// random peer to allow it to compete for a position among the
// downloaders. (This is known as an "optimistic unchoke".)
if (!allClients.isEmpty()) {
- PeerWireClient *client = allClients[QRandomGenerator::global()->bounded(allClients.size())];
+ PeerWireClient *client = allClients[QRandomGenerator::global()->bounded(int(allClients.size()))];
if (client->peerWireState() & PeerWireClient::ChokingPeer)
client->unchokePeer();
}
@@ -1191,7 +1191,7 @@ void TorrentClient::schedulePieceForClient(PeerWireClient *client)
piece = d->payloads.value(client);
if (!piece) {
QList<TorrentPiece *> values = d->pendingPieces.values();
- piece = values.value(QRandomGenerator::global()->bounded(values.size()));
+ piece = values.value(QRandomGenerator::global()->bounded(int(values.size())));
piece->inProgress = true;
d->payloads.insert(client, piece);
}
@@ -1248,7 +1248,7 @@ void TorrentClient::schedulePieceForClient(PeerWireClient *client)
++it;
}
if (!partialPieces.isEmpty())
- piece = partialPieces.value(QRandomGenerator::global()->bounded(partialPieces.size()));
+ piece = partialPieces.value(QRandomGenerator::global()->bounded(int(partialPieces.size())));
if (!piece) {
// Pick a random piece 3 out of 4 times; otherwise, pick either
@@ -1295,7 +1295,7 @@ void TorrentClient::schedulePieceForClient(PeerWireClient *client)
}
// Select one piece randomly
- pieceIndex = piecesReadyForDownload.at(QRandomGenerator::global()->bounded(piecesReadyForDownload.size()));
+ pieceIndex = piecesReadyForDownload.at(QRandomGenerator::global()->bounded(int(piecesReadyForDownload.size())));
delete [] occurrences;
} else {
// Make up a list of available piece indices, and pick
@@ -1306,7 +1306,7 @@ void TorrentClient::schedulePieceForClient(PeerWireClient *client)
if (incompletePiecesAvailableToClient.testBit(i))
values << i;
}
- pieceIndex = values.at(QRandomGenerator::global()->bounded(values.size()));
+ pieceIndex = values.at(QRandomGenerator::global()->bounded(int(values.size())));
}
// Create a new TorrentPiece and fill in all initial
@@ -1398,8 +1398,8 @@ int TorrentClient::requestBlocks(PeerWireClient *client, TorrentPiece *piece, in
// speedup comes from an increased chance of receiving
// different blocks from the different peers.
for (int i = 0; i < bits.size(); ++i) {
- int a = QRandomGenerator::global()->bounded(bits.size());
- int b = QRandomGenerator::global()->bounded(bits.size());
+ int a = QRandomGenerator::global()->bounded(int(bits.size()));
+ int b = QRandomGenerator::global()->bounded(int(bits.size()));
int tmp = bits[a];
bits[a] = bits[b];
bits[b] = tmp;
diff --git a/examples/widgets/mainwindows/mainwindow/toolbar.cpp b/examples/widgets/mainwindows/mainwindow/toolbar.cpp
index 6a5faf248f..fd510c8a57 100644
--- a/examples/widgets/mainwindows/mainwindow/toolbar.cpp
+++ b/examples/widgets/mainwindows/mainwindow/toolbar.cpp
@@ -264,7 +264,7 @@ void ToolBar::randomize()
QList<QAction *> randomized;
QList<QAction *> actions = this->actions();
while (!actions.isEmpty()) {
- QAction *action = actions.takeAt(QRandomGenerator::global()->bounded(actions.size()));
+ QAction *action = actions.takeAt(QRandomGenerator::global()->bounded(int(actions.size())));
randomized.append(action);
}
clear();