このページでは

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 をラップする単純なアダプタクラスであり、operator() のデフォルトの関数を、32 ビットの値を返す関数ではなく、QRandomGenerator::generate64() 関数に設定します。このクラスは、32 ビットではなく 64 ビットの値を必要とする標準ライブラリのアルゴリズムと組み合わせて使用することを目的としています。

その他の点については、このクラスは32ビット版と同じです。詳細については、QRandomGenerator のドキュメントを参照してください。

QRandomGeneratorも参照してください 。

メンバ型のドキュメント

QRandomGenerator64::result_type

operator() が返す型に対する typedef です。つまり、quint64 です。

operator()も参照してください 。

メンバ関数のドキュメント

quint64 QRandomGenerator64::generate()

64ビットの乱数を1つ生成して返します。

符号付き整数への型変換に関する注意:この関数が返すすべてのビットはランダムであるため、最上位ビットがセットされる確率は50%です。返り値を qint64 に型変換し、正の値を維持したい場合は、符号ビットをマスクする必要があります:

    qint64 value = QRandomGenerator64::global()->generate() & std::numeric_limits<qint64>::max();

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.