标签:
//原始QString
QString qs = QString::fromLocal8Bit("我的");
std::string strQs = qs.toStdString();
int qs_size = qs.length();//长度为3
int strQs_size = strQs.length();//长度8
//得到转换后的char*
char* p = new char[strQs_size];
memcpy(p, qs.toStdString().c_str(), strQs_size);
//再得到QString
std::string strQs1(p, strQs_size);
QString qs1 = QString::fromStdString(strQs1);
QT QString转char*,char*转QString;简单明了,看代码。
标签:
原文地址:http://www.cnblogs.com/fluteary/p/5554394.html