Qt string与QString之间的转换

string str;
QString qstr;

//从QString 到 std::string
str = qstr.toStdString();

//从std::string 到QString
qstr = QString::fromStdString(str);

-------------------------------------------------------------
std::string cstr;
QString qstring;

//从std::string 到QString
qstring = QString(QString::fromLocal8Bit(cstr.c_str()));

//从QString 到 std::string
cstr = string((const char *)qstring.toLocal8Bit());

你可能感兴趣的:(Qt,/,Qt,Creator)