Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to convert std::string to QString

Tags:

c++

string

qt

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

like image 509
Andrew Avatar asked Jun 05 '11 15:06

Andrew


1 Answers

string to const char*, then to qstring

std::string str("character/test/raw");
QString qstr(str.c_str());
qDebug() << qstr;
like image 110
Alessandro Pezzato Avatar answered Oct 10 '22 02:10

Alessandro Pezzato