QString和string的相互转换(不出现乱码)

转载:https://blog.csdn.net/chenjianqi0502/article/details/79400101

 

std::string cstr;

QString qstring;

//从std::string 到QString

qstring = QString(QString::fromLocal8Bit(cstr.c_str()));

//从QString 到 std::string

cstr = string((const char *)qstring.toLocal8Bit());

//不需要从gbk转到utf8

QString value_content = QString::fromStdString(vec[i].content);

QString value_classname = QString::fromStdString(vec[i].classname);

你可能感兴趣的:(QT)