How to convert string to double
General and Desktop
7
Posts
5
Posters
36.8k
Views
1
Watching
-
Hi karim24.
Did you try using "QString::toDouble()":http://qt-project.org/doc/qt-4.8/qstring.html#toDouble
Regards -
It is recommended to use QString for Qt projects but if you insists on using std::string you can easily find solution in similar topics:
- "C++ string to double conversion":http://stackoverflow.com/questions/4754011/c-string-to-double-conversion
- "How can I convert string to double in C++?":http://stackoverflow.com/questions/392981/how-can-i-convert-string-to-double-in-c
- "std::string to float or double":http://stackoverflow.com/questions/1012571/stdstring-to-float-or-double
-
This is a Qt forum, neither std::string nor stof() is part of Qt, and no other part of your question implicates Qt in any way. Hence my question.
You are probably getting errors, that you don't specify, because std::stof() is part of C++11 and your compiler, which you also did not specify, is defaulting to an earlier C++ standard. That's only a guess though.