http://zyoyoyo.diandian.com/post/2012-04-23/19218552
qstring wchar char 相互转化
QString to Wchar :
法一:WCHAR pathfile[100];
QString("\\\\.\\PHYSICALDRIVE0").toWCharArray(pathfile);
法二:
reinterpret_cast<constwchar_t*>(QString("ParaList").utf16())
Wchar to QString:
QString str;
wchar_t module_name[MAX_PATH];
GetModuleFileName(NULL,module_name,MAX_PATH);
module_name[MAX_PATH]='/0';
m_strUserDataPath=QString::fromWCharArray(module_name);
替换QString的某一位:
strExePath.replace(0,1,QChar(strExePath[0].toAscii()|0x20));
QString to char*
QByteArrayba1=m_strHardSerial.toLatin1();
constchar*c_str2=ba1.data();
QChar 转char :
.toAscii();
wcstombs(char* strDes, const wchar*, size_t nMax);这个函数的作用是把wchar转换为char。
char* strDes 为保存转换后的普通字符串,wchar* 要被转换的宽字符串。转换的最大长度。这里的长度是转换的个数,而不是字节长度。
mbstowcs() 就是一个相反的过程了,参数就不说了。