QRandomGenerator64 Class
QRandomGenerator64 类允许用户从一个高质量、无需初始化的随机数生成器中获取 64 位随机值。更多内容...
| 头文件: | #include <QRandomGenerator64> |
| CMake: | find_package(Qt6 REQUIRED COMPONENTS Core) target_link_libraries(mytarget PRIVATE Qt6::Core) |
| qmake: | QT += core |
| 继承自: | QRandomGenerator |
公共类型
公共函数
| quint64 | generate() |
| QRandomGenerator64::result_type | operator()() |
详细说明
QRandomGenerator64 是一个围绕QRandomGenerator 构建的简单适配器类,它将QRandomGenerator::generate64() 函数设为operator() 的默认实现,而非返回 32 位数值的函数。该类旨在与需要 64 位而非 32 位数值的标准库算法配合使用。
在其他所有方面,该类与原类保持一致。更多信息请参阅QRandomGenerator 的文档。
另请参阅 QRandomGenerator 。
成员函数文档
quint64 QRandomGenerator64::generate()
生成一个 64 位随机值并返回。
关于强制转换为有符号整数的说明:该函数返回的所有位都是随机的,因此最高有效位被设为1的概率为50%。若希望将返回值强制转换为 qint64 并保持其值为正,应屏蔽符号位:
另请参阅 QRandomGenerator 和QRandomGenerator::generate64()。
QRandomGenerator64::result_type QRandomGenerator64::operator()()
生成一个 64 位的随机数并返回该数值。
另请参阅 QRandomGenerator::generate() 和QRandomGenerator::generate64()。
© 2026 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.