summaryrefslogtreecommitdiffstats
path: root/tests/manual
diff options
context:
space:
mode:
Diffstat (limited to 'tests/manual')
-rw-r--r--tests/manual/cocoa/nativewidgets/main.cpp2
-rw-r--r--tests/manual/textrendering/textperformance/main.cpp21
-rw-r--r--tests/manual/windowchildgeometry/controllerwidget.cpp18
3 files changed, 19 insertions, 22 deletions
diff --git a/tests/manual/cocoa/nativewidgets/main.cpp b/tests/manual/cocoa/nativewidgets/main.cpp
index bfa97aa62f..3923e30de7 100644
--- a/tests/manual/cocoa/nativewidgets/main.cpp
+++ b/tests/manual/cocoa/nativewidgets/main.cpp
@@ -37,7 +37,7 @@ class ColorWidget : public QWidget
void changeColor()
{
- color.setHsv((qreal(qrand()) / RAND_MAX) * 50 + 200, s, s);
+ color.setHsv(QRandomGenerator::global()->bounded(50) + 200, s, s);
}
public:
diff --git a/tests/manual/textrendering/textperformance/main.cpp b/tests/manual/textrendering/textperformance/main.cpp
index 9bd6d036af..eb6d09b9c8 100644
--- a/tests/manual/textrendering/textperformance/main.cpp
+++ b/tests/manual/textrendering/textperformance/main.cpp
@@ -30,6 +30,7 @@
#include <QDialog>
#include <QFontDatabase>
#include <QPainter>
+#include <QRandomGenerator>
#include <QTime>
#include <QTimer>
@@ -93,17 +94,17 @@ public:
static const QString text = QLatin1String("Qt rocks!!!");
static const int textsPerPaint = 30;
for (int i = 0; i < textsPerPaint; i++) {
- const int fontSize = 4 + (qrand() % 5);
- const int fontWeight = (qrand() % 2) == 1 ? QFont::Normal : QFont::Bold;
- const bool fontItalic = (qrand() % 2) == 1;
+ const int fontSize = 4 + QRandomGenerator::global()->bounded(5);
+ const int fontWeight = QRandomGenerator::global()->bounded(2) == 1 ? QFont::Normal : QFont::Bold;
+ const bool fontItalic = QRandomGenerator::global()->bounded(2) == 1;
const QFont font("Default", fontSize, fontWeight, fontItalic);
p.setFont(font);
- p.setPen(QColor::fromHsv(qrand() % 359, 155 + qrand() % 100,
- 155 + qrand() % 100, 100 + qrand() % 155));
+ p.setPen(QColor::fromHsv(QRandomGenerator::global()->bounded(359), 155 + QRandomGenerator::global()->bounded(100),
+ 155 + QRandomGenerator::global()->bounded(100), 100 + QRandomGenerator::global()->bounded(155)));
const QSize textSize(p.fontMetrics().boundingRect(text).size());
const QPoint position(
- -textSize.width() / 2 + (qrand() % size.width()),
- textSize.height() / 2 + (qrand() % size.height()));
+ -textSize.width() / 2 + QRandomGenerator::global()->bounded(size.width()),
+ textSize.height() / 2 + QRandomGenerator::global()->bounded(size.height()));
p.drawText(position, text);
}
}
@@ -126,8 +127,8 @@ public:
QString text;
for (int i = 0; i < piecesPerPaint; ++i) {
- QString piece = QLatin1String(pieces[qrand() % piecesCount]);
- if (i == 0 || qrand() % 2) {
+ QString piece = QLatin1String(pieces[QRandomGenerator::global()->bounded(piecesCount)]);
+ if (i == 0 || QRandomGenerator::global()->bounded(2)) {
// Make this piece the beginning of a new sentence.
piece[0] = piece[0].toUpper();
if (i > 0)
@@ -160,7 +161,7 @@ public:
for (int i = 0; i < systemsPerPaint; i++) {
if (i > 0)
text.append(QLatin1Char(' '));
- text.append(samples.at(qrand() % samples.count()));
+ text.append(samples.at(QRandomGenerator::global()->bounded(samples.count())));
}
p.drawText(QRectF(QPointF(0, 0), QSizeF(size)),
Qt::AlignTop | Qt::AlignAbsolute | Qt::TextWordWrap, text);
diff --git a/tests/manual/windowchildgeometry/controllerwidget.cpp b/tests/manual/windowchildgeometry/controllerwidget.cpp
index 1d18c5d51b..871313d983 100644
--- a/tests/manual/windowchildgeometry/controllerwidget.cpp
+++ b/tests/manual/windowchildgeometry/controllerwidget.cpp
@@ -29,16 +29,12 @@
#include "controllerwidget.h"
#include <controls.h>
-#if QT_VERSION >= 0x050000
-# include <QtWidgets>
-# include <QWindow>
-# include <QBackingStore>
-# include <QPaintDevice>
-# include <QPainter>
-#else
-# include <QtGui>
-#endif
-
+#include <QtWidgets>
+#include <QWindow>
+#include <QBackingStore>
+#include <QPaintDevice>
+#include <QPainter>
+#include <QRandomGenerator>
#include <QResizeEvent>
CoordinateControl::CoordinateControl(const QString &sep) : m_x(new QSpinBox), m_y(new QSpinBox)
@@ -280,7 +276,7 @@ public:
explicit Window(QWindow *parent = 0)
: QWindow(parent)
, m_backingStore(new QBackingStore(this))
- , m_color(Qt::GlobalColor(qrand() % 18))
+ , m_color(Qt::GlobalColor(QRandomGenerator::global()->bounded(18)))
{
setObjectName(QStringLiteral("window"));
setTitle(tr("TestWindow"));