gpt4 book ai didi

c++ - Qt错误: 'const class QString' has no member named 'toStdString'

转载 作者:塔克拉玛干 更新时间:2023-11-03 02:11:27 27 4
gpt4 key购买 nike

我收到此错误 error: 'const class QString' has no member named 'toStdString' 虽然 QString 有它。 (link) .

代码

    std::string Message::toStdString() const 
{
return m_string.toStdString();
}

最佳答案

直接从这里复制答案:

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();

关于c++ - Qt错误: 'const class QString' has no member named 'toStdString' ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15806452/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com