//原始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);
时间: 2024-11-08 18:56:27