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. std::stold() does not work with Qt in Linux
Forum Updated to NodeBB v4.3 + New Features

std::stold() does not work with Qt in Linux

Scheduled Pinned Locked Moved Solved General and Desktop
3 Posts 2 Posters 194 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.
  • T Offline
    T Offline
    Tiago M.Pinto
    wrote on 25 Nov 2020, 16:34 last edited by
    #1

    Hi!

    I am trying to get a long double value from a string using the std::stold function but I can only get the integer part (including the dot). This issue only seems to exist when I use Qt in Linux (in Windows works fine) but if I run that part of the code without using any Qt class, I get the the variable with full precision as expected.

    I know that Qt provides other methods to implement this but I would like to use standard C++ libraries in this part of the code since it may be necessary to build it without Qt.

    Any thoughts?

    Regards!

    1 Reply Last reply
    0
    • C Offline
      C Offline
      Christian Ehrlicher
      Lifetime Qt Champion
      wrote on 25 Nov 2020, 16:43 last edited by Christian Ehrlicher
      #2

      Qt is changing the locale. You have to set it back to "C" when you want to parse floating point numbers.

      /edit: you must be aware that everyone can change the locale so before you pass stuff you should make sure that the locale is correct no matter if you use Qt or not.

      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
      4
      • T Offline
        T Offline
        Tiago M.Pinto
        wrote on 25 Nov 2020, 16:54 last edited by
        #3

        Thank you! It solved the problem.

        1 Reply Last reply
        0

        1/3

        25 Nov 2020, 16:34

        • 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