Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

error: 'to_string' is not a member of 'std' ^



  • Hello,

    Trying to convert string to int in QT:

    #include <string>
    
    std::string g = std::to_string(4);
    

    Compiler shows error:

    error: 'to_string' is not a member of 'std'
    

    Why? How to fix it?



  • this has nothing to do with Qt.
    std::to_string is C++11, you have to make sure you have a recent enough compiler and to enable C++11 features. If you use Qt Creator you should add CONFIG += c++11 in your .pro file and re-run qmake

    Alternatively you can #include <sstream> and use std::stringstream gstream; gstream << 4; std::string g=gstream.str();


Log in to reply