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

转自http://hi.baidu.com/zj41342626/blog/item/3650cd82a381e9b00cf4d2c9.html

//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."));


你可能感兴趣的:(编程,c,windows,qt)