qt6随机数

qt6中不能再使用 qsrand 与qrand.应当使用 QRandomGenerator

比如生成0到300的随机数

#include 

int rand = QRandomGenerator::global()->bounded(0,300);

QRandomGenerator may be used to generate random values from a high-quality random number generator. Like the C++ random engines, QRandomGenerator can be seeded with user-provided values through the constructor. When seeded, the sequence of numbers generated by this class is deterministic. That is to say, given the same seed data, QRandomGenerator will generate the same sequence of numbers. But given different seeds, the results should be considerably different.

你可能感兴趣的:(qt,定时器)