Qt error: 'const class QString' does not have a name named 'toStdString'

I get this error error: 'const class QString' has no member named 'toStdString' , although QString has it. (link) .

Code

  std::string Message::toStdString() const { return m_string.toStdString(); } 
+4
source share
1 answer

The answer is directly copied here:

How to convert QString to std :: string?

 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(); 
+2
source

All Articles