Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
Loading...
Searching...
No Matches
src_corelib_global_qrandom.cpp
Go to the documentation of this file.
1// Copyright (C) 2018 Intel Corporation.
2// Copyright (C) 2018 The Qt Company Ltd.
3// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
4
8
14
16 int x = QRandomGenerator::global()->generate();
17 int y = QRandomGenerator::global()->generate();
18 int w = QRandomGenerator::global()->bounded(16384);
19 int h = QRandomGenerator::global()->bounded(16384);
21
23 std::uniform_real_distribution dist(1, 2.5);
26
28 std::seed_seq sseq(seedBuffer, seedBuffer + len);
31
33 std::seed_seq sseq(begin, end);
36
38 while (z--)
41
43 std::generate(begin, end, [this]() { return generate(); });
45
47 std::generate(begin, end, []() { return QRandomGenerator::global()->generate64(); });
49
51 QList<quint32> list;
53 QRandomGenerator::global()->fillRange(list.data(), list.size());
55
58 QRandomGenerator::global()->fillRange(array);
60
63 return std::generate_canonical<qreal, std::numeric_limits<qreal>::digits>(rd);
65
67 return generateDouble() * highest;
69
73
75 quint32 v = QRandomGenerator::global()->bounded(1000, 2000);
77
79 return QColor::fromRgb(QRandomGenerator::global()->generate());
81
83 qint64 value = QRandomGenerator64::global()->generate() & std::numeric_limits<qint64>::max();
static QColor fromRgb(QRgb rgb) noexcept
Static convenience function that returns a QColor constructed from the given QRgb value rgb.
Definition qcolor.cpp:2369
qsizetype size() const noexcept
Definition qlist.h:397
pointer data()
Definition qlist.h:431
void resize(qsizetype size)
Definition qlist.h:403
\inmodule QtCore
Definition qrandom.h:209
static Q_DECL_CONST_FUNCTION Q_CORE_EXPORT QRandomGenerator64 * global()
Definition qrandom.cpp:1134
\inmodule QtCore \reentrant
Definition qrandom.h:21
quint32 generate()
Generates a 32-bit random quantity and returns it.
Definition qrandom.h:48
static Q_DECL_CONST_FUNCTION QRandomGenerator * global()
\threadsafe
Definition qrandom.h:275
quint64 generate64()
Generates a 64-bit random quantity and returns it.
Definition qrandom.h:53
EGLOutputLayerEXT EGLint EGLAttrib value
[5]
GLsizei const GLfloat * v
[13]
GLuint GLfloat GLfloat GLfloat GLfloat GLfloat z
GLint GLint GLint GLint GLint x
[0]
GLfloat GLfloat GLfloat w
[0]
GLuint GLuint end
GLint y
GLfloat GLfloat GLfloat GLfloat h
GLenum array
GLenum GLsizei len
#define Q_ASSERT(cond)
Definition qrandom.cpp:47
QtPrivate::QRegularExpressionMatchIteratorRangeBasedForIterator begin(const QRegularExpressionMatchIterator &iterator)
unsigned int quint32
Definition qtypes.h:50
long long qint64
Definition qtypes.h:60
QRandomGenerator prng2(1234)
QList< quint32 > list
[8]
return generateDouble() *highest
[11]
QRandomGenerator64 rd
[10]
std::seed_seq sseq(seedBuffer, seedBuffer+len)
[3]
QRandomGenerator prng1(1234)
[0]
QRandomGenerator generator(sseq)
std::uniform_real_distribution dist(1, 2.5)
[2]