[Qt] QString 和 char* 转换

(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);
posted @ 2015-10-03 10:36  MDGSF  阅读(186)  评论(0编辑  收藏  举报