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 608 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 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

    JonBJ 1 Reply Last reply
    0
    • M MatteoMB

      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

      JonBJ Online
      JonBJ Online
      JonB
      wrote on 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
      • Kent-DorfmanK Offline
        Kent-DorfmanK Offline
        Kent-Dorfman
        wrote on last edited by
        #3

        std::istringstream
        there are tons of examples online.

        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