QT编程中的char*,wchar_t*与QString之间的转换

//QString to wchar_t:
const wchar_t * encodedName = reinterpret_cast<const wchar_t *>(fileName.utf16());

//QString to char * (general case):
const char * tmp = str.toUtf8().constData();

//wchar_t* to QString
wchar_t szMsg[100] = {0};
_stprintf(szMsg,L"Connect [%s] failed!",ssid);
QString str1= QString::fromWCharArray(szMsg);

//char* to QString
QStirng str2(tr("Please try again later."));

posted @ 2021-09-05 21:54  裘庄三少  阅读(708)  评论(0编辑  收藏  举报