int number; int randomValue = qrand() % number; returns a random number randomValue with 0 <= randomValue < number . qrand() is declared in QtGlobal which is #included by many other Qt files. int value; QString aString = QString::number(value);
Using the random index number, we have generated the random character from the string alphabet. We then used the StringBuilder class to append all the characters together. If we want to change the random string into lower case, we can use the toLowerCase() method of the String .
Is there any function or something like that by which I can create totally random strings or numbers?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With