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. How to convert string to float
Forum Update on Monday, May 27th 2025

How to convert string to float

Scheduled Pinned Locked Moved Unsolved General and Desktop
3 Posts 3 Posters 607 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.
  • M Offline
    M Offline
    MatteoMB
    wrote on 31 Jul 2021, 13:45 last edited by
    #1

    Hi all!
    It seems like a stupid question, but in Qt Creator neither std::stof nor std::atoi are working to convert a std::string to a floating point value.
    The strangest thing is that it works fine running in Debug mode, but running the application normally, the decimal digits desappear from the variable.
    I'm new to Qt, maybe there's something I'm missing.
    Thank you in advance!
    Re: How to convert string to double

    J 1 Reply Last reply 31 Jul 2021, 14:11
    0
    • M MatteoMB
      31 Jul 2021, 13:45

      Hi all!
      It seems like a stupid question, but in Qt Creator neither std::stof nor std::atoi are working to convert a std::string to a floating point value.
      The strangest thing is that it works fine running in Debug mode, but running the application normally, the decimal digits desappear from the variable.
      I'm new to Qt, maybe there's something I'm missing.
      Thank you in advance!
      Re: How to convert string to double

      J Offline
      J Offline
      JonB
      wrote on 31 Jul 2021, 14:11 last edited by
      #2

      @MatteoMB
      Hello and welcome.

      Qt Creator is not a compiler. And Qt is not a language. So there is no concept of them "making/preventing something work".

      What you ask about sounds like you are just using C++ std library and have incorrect code. Nothing to do with Qt. You could paste your code here (if it's short!), someone may answer, or take it to a more appropriate C++ forum.

      1 Reply Last reply
      2
      • K Offline
        K Offline
        Kent-Dorfman
        wrote on 1 Aug 2021, 02:43 last edited by
        #3

        std::istringstream
        there are tons of examples online.

        1 Reply Last reply
        0

        1/3

        31 Jul 2021, 13:45

        • Login

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