Results 1 to 2 of 2

Thread: How to convert decimal to hexadecimal with Qt programming?

  1. #1
    Join Date
    Aug 2025
    Posts
    1
    Qt products
    Qt4
    Platforms
    Windows

    Default How to convert decimal to hexadecimal with Qt programming?

    Hello,
    How to convert decimal to hexadecimal with Qt programming? Such as 69 switch to 45, 56 switch to 38 and so on... I try like this:
    Qt Code:
    1. QString str = QString::number(s.at(i).unicode());
    2. bool ok;
    3. qDebug() << str.toUtf8();
    To copy to clipboard, switch view to plain text mode 
    but failed. I need to convert this string "E8A5" ASCII switch to hexadecimal number or string.
    - Nancy -

  2. #2
    Join Date
    Jul 2008
    Location
    Germany
    Posts
    520
    Thanks
    13
    Thanked 77 Times in 75 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: How to convert decimal to hexadecimal with Qt programming?

    edit: removed old stuff that did not answer question

    You can use QString::toInt or QString::toUInt to convert the hex string to a number, and then QString::number to get back to a string.

    Ginsengelf
    Last edited by Ginsengelf; 5th August 2025 at 13:46.

Similar Threads

  1. Replies: 2
    Last Post: 13th October 2014, 12:32
  2. QLineEdit for editing hexadecimal and decimal numbers
    By schall_l in forum Qt Programming
    Replies: 2
    Last Post: 28th April 2012, 11:38
  3. Replies: 4
    Last Post: 24th July 2009, 08:48
  4. converting the value from hexadecimal to decimal value
    By jjbabu in forum Qt Programming
    Replies: 2
    Last Post: 16th November 2007, 10:24
  5. How to convert binary data to hexadecimal data
    By yellowmat in forum Newbie
    Replies: 4
    Last Post: 8th March 2006, 16:17

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.