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. Reading Number
Qt 6.11 is out! See what's new in the release blog

Reading Number

Scheduled Pinned Locked Moved Unsolved General and Desktop
c++
5 Posts 3 Posters 572 Views 2 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.
  • A Offline
    A Offline
    aim0d
    wrote on last edited by aim0d
    #1

    Hi!
    Is it possible to let Qt Creator read double number like this -> 15,5 instead of 15.5
    Because I'm using some formula and qDebug shows me 0 instead of the full number after the comma.

    I'm new to Qt, but I saw there is "replace" as method but it's only for QString (my number are initialize as double)

    JonBJ 1 Reply Last reply
    0
    • A aim0d

      Hi!
      Is it possible to let Qt Creator read double number like this -> 15,5 instead of 15.5
      Because I'm using some formula and qDebug shows me 0 instead of the full number after the comma.

      I'm new to Qt, but I saw there is "replace" as method but it's only for QString (my number are initialize as double)

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

      @aim0d
      I presume you are talking about your Qt program, not Qt Creator? That is just an IDE for progam development.

      How (what code) are you using to convert a numerical string to a number? Or are you talking about typing that number somewhere in Creator??

      A 1 Reply Last reply
      0
      • Paul ColbyP Offline
        Paul ColbyP Offline
        Paul Colby
        wrote on last edited by
        #3

        Hi @aim0d, if you're meaning to handle the comma because that's the local user's format, you might like to try out QLocale::toDouble() - it'll interpret , and . characters according the user's locale settings.

        Cheers.

        A 1 Reply Last reply
        1
        • JonBJ JonB

          @aim0d
          I presume you are talking about your Qt program, not Qt Creator? That is just an IDE for progam development.

          How (what code) are you using to convert a numerical string to a number? Or are you talking about typing that number somewhere in Creator??

          A Offline
          A Offline
          aim0d
          wrote on last edited by
          #4

          @JonB Sorry, yes, i'm talking about Qt program.
          I'm getting the number from QLineEdit in creator and getting in mainWindow as ui->omug->text().toDouble();

          But I have several operation that ends up being saved as several double name = result
          and I have to sum these result between them

          I dont know If I'm been clear, but english is not my first language and I'm trying to sum up my code to post it but having trouble

          1 Reply Last reply
          0
          • Paul ColbyP Paul Colby

            Hi @aim0d, if you're meaning to handle the comma because that's the local user's format, you might like to try out QLocale::toDouble() - it'll interpret , and . characters according the user's locale settings.

            Cheers.

            A Offline
            A Offline
            aim0d
            wrote on last edited by
            #5

            @Paul-Colby Yes, that what I was meaning. I'm gonna try thanks.

            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