Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Display hexdecima format
Forum Updated to NodeBB v4.3 + New Features

Display hexdecima format

Scheduled Pinned Locked Moved Solved General and Desktop
5 Posts 4 Posters 365 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • taku-sT Offline
    taku-sT Offline
    taku-s
    wrote on last edited by
    #1

    Hi all.

    I want to display the string entered in lineEdit_1 in hexadecimal format in LineEdit_2.
    For example, if I enter 12AB, yI want to display 31 32 41 42.

    What should I do?

    Thank you.

    aha_1980A 1 Reply Last reply
    0
    • taku-sT taku-s

      Hi all.

      I want to display the string entered in lineEdit_1 in hexadecimal format in LineEdit_2.
      For example, if I enter 12AB, yI want to display 31 32 41 42.

      What should I do?

      Thank you.

      aha_1980A Offline
      aha_1980A Offline
      aha_1980
      Lifetime Qt Champion
      wrote on last edited by
      #3

      Hi @taku-s,

      just to add an example to @ChrisW67's good hints:

      lineEdit_2->setText(lineEdit1->text().toLocal8Bit().toHex(' '));
      

      Note: if your text only contains ASCII characters, you can replace toLocal8Bit() with toLatin1(). If not, you should also check if toUtf8() might be the better solution, but keep in mind that one character in lineEdit_1 might result in several characters in lineEdit_2 then.

      Regards

      Qt has to stay free or it will die.

      1 Reply Last reply
      4
      • C Offline
        C Offline
        ChrisW67
        wrote on last edited by
        #2

        QString::toLocal8Bit() (or one of its sibling functions) and QByteArray::toHex()

        1 Reply Last reply
        5
        • taku-sT taku-s

          Hi all.

          I want to display the string entered in lineEdit_1 in hexadecimal format in LineEdit_2.
          For example, if I enter 12AB, yI want to display 31 32 41 42.

          What should I do?

          Thank you.

          aha_1980A Offline
          aha_1980A Offline
          aha_1980
          Lifetime Qt Champion
          wrote on last edited by
          #3

          Hi @taku-s,

          just to add an example to @ChrisW67's good hints:

          lineEdit_2->setText(lineEdit1->text().toLocal8Bit().toHex(' '));
          

          Note: if your text only contains ASCII characters, you can replace toLocal8Bit() with toLatin1(). If not, you should also check if toUtf8() might be the better solution, but keep in mind that one character in lineEdit_1 might result in several characters in lineEdit_2 then.

          Regards

          Qt has to stay free or it will die.

          1 Reply Last reply
          4
          • taku-sT Offline
            taku-sT Offline
            taku-s
            wrote on last edited by
            #4

            Thank you everyone
            I was able to solve

            Pablo J. RoginaP 1 Reply Last reply
            1
            • taku-sT taku-s

              Thank you everyone
              I was able to solve

              Pablo J. RoginaP Offline
              Pablo J. RoginaP Offline
              Pablo J. Rogina
              wrote on last edited by
              #5

              @taku-s said in Display hexdecima format:

              I was able to solve

              great, so please don't forget to mark your post as solved!

              Upvote the answer(s) that helped you solve the issue
              Use "Topic Tools" button to mark your post as Solved
              Add screenshots via postimage.org
              Don't ask support requests via chat/PM. Please use the forum so others can benefit from the solution in the future

              1 Reply Last reply
              1

              • Login

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • Users
              • Groups
              • Search
              • Get Qt Extensions
              • Unsolved