Results 1 to 7 of 7

Thread: Encoding a QString to No.?

  1. #1
    Join Date
    Dec 2006
    Posts
    211
    Thanks
    27
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Question Encoding a QString to No.?

    Hi All,

    I m using QT 4.1.5 on my MAC.
    I have a QString to which I want to Encode to Numbers and then want to write it to a file.

    So if anyone know how I can do it then plz help me.

    Thanks.

  2. #2
    Join Date
    Jan 2006
    Location
    Third rock from the sun
    Posts
    106
    Thanks
    17
    Thanked 6 Times in 6 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Encoding a QString to No.?

    Quote Originally Posted by vishal.chauhan View Post
    Hi All,

    I m using QT 4.1.5 on my MAC.
    I have a QString to which I want to Encode to Numbers and then want to write it to a file.

    So if anyone know how I can do it then plz help me.

    Thanks.
    For QStrings there is a toInt( ) (or toDouble( ), etc) function that will convert the string to the appropriate number.
    http://doc.trolltech.com/4.1/qstring.html#toInt

    To convert a number into a string, there is a static function QString::number( int num, int base ) http://doc.trolltech.com/4.1/qstring.html#number that returns a QString.

  3. #3
    Join Date
    Dec 2006
    Posts
    211
    Thanks
    27
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Default Re: Encoding a QString to No.?

    Thanks for Reply.

    But I want Encoding of QString to number as

    If I have a QString like QT CENTER then it will encode it to something like 275161967.

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Encoding a QString to No.?

    What kind of encoding would you like to use?

  5. #5
    Join Date
    Dec 2006
    Posts
    211
    Thanks
    27
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Default Re: Encoding a QString to No.?

    Any type of encoding.

    It should be simple or complex.

  6. #6
    Join Date
    Feb 2006
    Location
    Romania
    Posts
    2,744
    Thanks
    8
    Thanked 541 Times in 521 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Encoding a QString to No.?

    How did you compute that number for QT CENTRE?
    For a given char you can get its unicode code with QChar::unicode();

    Maybe you can use that unique value to build a number from a string.

    Regards

  7. #7
    Join Date
    Aug 2007
    Location
    Russia
    Posts
    19
    Thanks
    1
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Encoding a QString to No.?

    Quote Originally Posted by vishal.chauhan View Post
    Thanks for Reply.

    But I want Encoding of QString to number as

    If I have a QString like QT CENTER then it will encode it to something like 275161967.
    Try to search in the Internet about hashing. If you want to encode it into one integer, try CRC32 algorithm. Remenber, that hashing is irreversible...

Similar Threads

  1. QString static callback function from CURL
    By tpf80 in forum Qt Programming
    Replies: 12
    Last Post: 16th May 2007, 20:47
  2. Convert from iso-8859-1 to... Something else :-)
    By Nyphel in forum Qt Programming
    Replies: 4
    Last Post: 7th March 2007, 17:59
  3. QSqlQueryModel + set Write
    By raphaelf in forum Qt Programming
    Replies: 7
    Last Post: 5th June 2006, 08:55
  4. Converting QString to unsigned char
    By salston in forum Qt Programming
    Replies: 3
    Last Post: 24th April 2006, 22:10
  5. [SOLVED] Widget plugin ... how to ?
    By yellowmat in forum Newbie
    Replies: 10
    Last Post: 29th January 2006, 20:41

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
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.