I'm trying that sample code and it crashes, in visualc++ 2010
QString fileName = "helloworld";
std::string str = fileName.toStdString();
I'm trying that sample code and it crashes, in visualc++ 2010
QString fileName = "helloworld";
std::string str = fileName.toStdString();
How to convert QString to std::string?
One of the things you should remember when converting QString to std::string is the fact that QString is UTF-16 encoded while std::string... May have any encodings.
QString qs;
// Either this if you use UTF-8 anywhere
std::string utf8_text = qs.toUtf8().constData();
// or this if you on Windows :-)
std::string current_locale_text = qs.toLocal8Bit().constData();
std::string str(fileName.toStdString());
if you want str to contain a copy of the qstring