MDGSF Software Engineer

[Qt] QString 和 char* 转换

2016-03-11
Qt

(1) QString 转 char*

char acResult[10240];
//QByteArray baResult = strResult.toLatin1();
QByteArray baResult = strResult.toLocal8Bit();
char *pcResult = baResult.data();
strcpy(acResult, pcResult);

(2) char* 转QString

char acName[] = "huang";
QString strName = QString(QLatin1String(acName));
QString strName = QString::fromUtf8(acName);

weixingongzhonghao

Comments

Content