8

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

2 Answers 2

9

string to const char*, then to qstring

std::string str("character/test/raw");
QString qstr(str.c_str());
qDebug() << qstr;
Sign up to request clarification or add additional context in comments.

Comments

6

Is your QT compiled with STL compatible enabled option?

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

3 Comments

I've installed the vc++2008 compiled last version from qt.nokia.com
qDebug() << QString::fromUtf8(str.data(), str.size()); That helped, thanks
@Andrew QString::fromUtf8( str.c_str() ) should be enough.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.