Hello everybody,

I am able to generate a number..

But i get for example number 5 and 6 a lot, and 1 or 3 never..

How could i optimized my random?

Thanks

Qt Code:
  1. int max;
  2. QSqlQuery count("select count(words_id) from words_tbl");
  3. while(count.next())
  4. {
  5. max = count.value(0).toInt();
  6. }
  7.  
  8. //random
  9. int a = (1 + ( rand() % ( max - 1 + 1 ) ));
  10. QString b = QString::number(a);
To copy to clipboard, switch view to plain text mode