Use of qsrand, random method that is not random
If you call the qsrand Qt function to initialize the seed, you must call the qrand Qt function to generate a random number, not the rand function from the standard library. the seed initialization for the rand function is srand. Sorry for the dig up.
If you make the call fast enough the value of QTime::currentTime().msec()
will not change, and you're basically re-seeding qsrand
with the same seed, causing the next random number generated to be the same as the prior one.
Because if you call randomize
more than once in a millisecond (which is rather likely at current CPU clock speeds), you are seeding the RNG with the same value. This is guaranteed to produce the same output from the RNG.
Random-number generators are only meant to be seeded once. Seeding them multiple times does not make the output extra random, and in fact (as you found) may make it much less random.