Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Qt error: 'const class QString' has no member named 'toStdString'

I am getting this error error: 'const class QString' has no member named 'toStdString' though QString has it. (link).

The code

    std::string Message::toStdString() const 
    {
        return m_string.toStdString();
    }
like image 675
Ashot Avatar asked Oct 21 '22 13:10

Ashot


1 Answers

Answer directly copied from 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();
like image 166
Vaibhav Desai Avatar answered Nov 03 '22 06:11

Vaibhav Desai