PDA

View Full Version : random alphabets



hema
20th July 2011, 11:01
hi,

how to retrieve alphabets randomly?

regards,
hema.

mcosta
20th July 2011, 11:27
how to retrieve alphabets randomly?


What do you means?

Lykurg
20th July 2011, 14:01
I guess it is a random character you want. For that see QChar::QChar(int code) with a random number between 97 and 122 (qrand and qsrand and the modulo operator and the +operator :-).

mvuori
20th July 2011, 17:23
QChar::QChar(int code) between 97-122 would only return lowercase ASCII characters, which might not be sufficient in many countries. Getting a set of meaningful characters or the local alphabet might not be easy, but for any purpose the character set from which to do the random selection could be expressed as a customized QString (included with the application perhaps as a resource) and a character selected with QString::at ( int position ). Now we would generate random numbers between zero and ourCharacterSetString.size() - 1;