三木目 发表于 2021-12-16 12:45:27

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



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 = {0};
_stprintf(szMsg,L"Connect [%s] failed!",ssid);
QString str1= QString::fromWCharArray(szMsg);

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


页: [1]
查看完整版本: QT编程中的char*,wchar_t*与QString之间的转换