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. Retrieve hexadecimal values from QLineEdit
Forum Updated to NodeBB v4.3 + New Features

Retrieve hexadecimal values from QLineEdit

Scheduled Pinned Locked Moved Solved General and Desktop
3 Posts 2 Posters 594 Views
  • 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.
  • R Offline
    R Offline
    rtvideo
    wrote on last edited by rtvideo
    #1

    I want to be able to retrieve a user inputted hexadecimal number and put it into a variable from a QLineEdit. I have:

    uint data_str = this->ui->lineEdit_3->text().toUInt();
    

    But when evaluating what data_str holds, it will return 0 every time. Does anyone know how if I typed 0x30 into the LineEdit, the data_str would hold a value of 48?

    Doing:

    QString data_str = this->ui->lineEdit_3->text();
    uint d = data_str.toUInt();
    

    Retruns a value of 0 as well.

    1 Reply Last reply
    0
    • Christian EhrlicherC Offline
      Christian EhrlicherC Offline
      Christian Ehrlicher
      Lifetime Qt Champion
      wrote on last edited by
      #2

      @rtvideo said in Retrieve hexadecimal values from QLineEdit:

      Does anyone know how if I typed 0x30 into the LineEdit, the data_str would hold a value of 48?

      Yes, fix your use of QString::toUInt()

      Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
      Visit the Qt Academy at https://academy.qt.io/catalog

      1 Reply Last reply
      3
      • R Offline
        R Offline
        rtvideo
        wrote on last edited by
        #3
        This post is deleted!
        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