开发者

how to convert std::string to QString

I have a problem:

std::string str("character/test/raw");
qDebug() << QString::fromStdString(str);

and the output is:

"]AIIIIIIIIIIIIIIIIIIIIIIIIIIIII"

I think the problem is in encoding but don't know how to fix it. Please 开发者_如何学运维help


string to const char*, then to qstring

std::string str("character/test/raw");
QString qstr(str.c_str());
qDebug() << qstr;


Is your QT compiled with STL compatible enabled option?

Maybe you can use fromUtf8 or one of other static functions of QString.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜