4
In QT Creator 5, how do I convert Integer to string? In Visual Studio 2012 there was the command:
std::to_string(10);
But it doesn’t work on QT. I tried to:
#include <QCoreApplication>
#include <iostream>
#include <string>
int main(int argc, char *argv[])
{
QCoreApplication a(argc, argv);
std::cout << std::to_string(10);
return a.exec();
}
That is the mistake:
G:\PROJETOS\CPP\untitled1\main.cpp:7: error: 'to_string' is not a member of 'std'
std::cout << std::to_string(10);
^
You want to convert to
std::stringorQString? Put the code you are trying to do, the problem may be another. And put what error or problem occurred.– Maniero
For Std::string.
– Gabriel Sales
Give me more details to complement the answer. Enter the whole code. http://answall.com/help/mcve
– Maniero
Why use
std::string, you are trying to modify an existing code?– Guilherme Nascimento
The code you posted doesn’t have what you asked for. And it’s not complete.
– Maniero
There. That’s the way it is, there’s nothing else.
– Gabriel Sales
If you are going to write on the console and use no Qt feature, why are you using
QCoreApplication? Which compiler is being used? Is it Mingw? Which version?– Maniero
It’s just an example. I need to use on this occasion.
– Gabriel Sales
To enable C++11 in Qtcreator add
CONFIG += C++11in the project configuration file (the.pro). This if the compiler supports C++11.– Lucas Lima
I don’t know what the ultimate purpose of the code is, but usually if you’re going to use Qt, a common option is to use the types available in Qcore, mainly to get peace of mind when porting to various platforms and/or compilers.
– Bacco