Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Special Interest Groups
  3. C++ Gurus
  4. error: 'to_string' is not a member of 'std' ^
Forum Updated to NodeBB v4.3 + New Features

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

Scheduled Pinned Locked Moved Solved C++ Gurus
2 Posts 2 Posters 12.5k 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.
  • C Offline
    C Offline
    column
    wrote on 18 Apr 2018, 15:14 last edited by
    #1

    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
    0
    • V Offline
      V Offline
      VRonin
      wrote on 18 Apr 2018, 15:41 last edited by VRonin
      #2

      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
      2

      1/2

      18 Apr 2018, 15:14

      • Login

      • Login or register to search.
      1 out of 2
      • First post
        1/2
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved