Results 1 to 4 of 4

Thread: random alphabets

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    4,380
    Thanks
    19
    Thanked 1,005 Times in 913 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60
    Wiki edits
    5

    Default Re: random alphabets

    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 :-).

  2. #2
    Join Date
    May 2011
    Posts
    239
    Thanks
    4
    Thanked 35 Times in 35 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Symbian S60

    Default Re: random alphabets

    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;

Similar Threads

  1. random number
    By pingus in forum Qt Programming
    Replies: 3
    Last Post: 6th July 2011, 18:22
  2. Regex to filter words containing english alphabets
    By dipeshtech in forum Qt Programming
    Replies: 12
    Last Post: 1st April 2011, 00:24
  3. Possible to get random value in QMultiHash/Map?
    By weevil in forum Qt Programming
    Replies: 2
    Last Post: 29th June 2010, 11:00
  4. Replies: 1
    Last Post: 7th April 2010, 16:26
  5. random
    By raphaelf in forum General Programming
    Replies: 9
    Last Post: 6th June 2007, 12:33

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.