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. convert QLineEdit text to Hex Decimal Value in c++
Forum Updated to NodeBB v4.3 + New Features

convert QLineEdit text to Hex Decimal Value in c++

Scheduled Pinned Locked Moved Solved General and Desktop
3 Posts 2 Posters 347 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.
  • Ramkumar MohanR Offline
    Ramkumar MohanR Offline
    Ramkumar Mohan
    wrote on last edited by
    #1

    I Wrote this code,

    void MainWindow::on_ConvertButton_pressed()
    {
    const std::string test="BM1010";
    std::ostringstream result;
    result << std::setw(2) << std::setfill('0') << std::hex << std::uppercase;
    std::copy(test.begin(), test.end(), std::ostream_iterator<unsigned int>(result, " "));
    std::cout << test << ":" << result.str() << std::endl;
    }

    Output :-

       BM1010 : 42 4D 31 30 31 30 
    

    This code works with String = "BM1010" to Hex Decimal Value.
    and, I want to convert QLineEdit text to hex decimal code.

    JonBJ 1 Reply Last reply
    0
    • Ramkumar MohanR Ramkumar Mohan

      I Wrote this code,

      void MainWindow::on_ConvertButton_pressed()
      {
      const std::string test="BM1010";
      std::ostringstream result;
      result << std::setw(2) << std::setfill('0') << std::hex << std::uppercase;
      std::copy(test.begin(), test.end(), std::ostream_iterator<unsigned int>(result, " "));
      std::cout << test << ":" << result.str() << std::endl;
      }

      Output :-

         BM1010 : 42 4D 31 30 31 30 
      

      This code works with String = "BM1010" to Hex Decimal Value.
      and, I want to convert QLineEdit text to hex decimal code.

      JonBJ Offline
      JonBJ Offline
      JonB
      wrote on last edited by
      #2

      @Ramkumar-Mohan
      So replace the const std::string test="BM1010"; with the desired QLineEdit::text(). What else is there to say, I don't know why you are asking a question?

      Ramkumar MohanR 1 Reply Last reply
      2
      • JonBJ JonB

        @Ramkumar-Mohan
        So replace the const std::string test="BM1010"; with the desired QLineEdit::text(). What else is there to say, I don't know why you are asking a question?

        Ramkumar MohanR Offline
        Ramkumar MohanR Offline
        Ramkumar Mohan
        wrote on last edited by
        #3

        @JonB

        Now, Working Fine Thank you

        1 Reply Last reply
        0

        • Login

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