Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Forum Updated on Feb 6th

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

    C++ Gurus
    2
    2
    9879
    Loading More Posts
    • 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.
    • C
      column last edited by

      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?

      1 Reply Last reply Reply Quote 0
      • V
        VRonin last edited by VRonin

        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();

        "La mort n'est rien, mais vivre vaincu et sans gloire, c'est mourir tous les jours"
        ~Napoleon Bonaparte

        On a crusade to banish setIndexWidget() from the holy land of Qt

        1 Reply Last reply Reply Quote 2
        • First post
          Last post