示例:
QString str = QString::fromLocal8Bit("12345677888888连连xx");
LPCWSTR name;
wchar_t* str2 = new wchar_t[str.size() + 1];
int len1=str.toWCharArray(str2);
str2[len1] = '\0';//不添加这个,会有乱码
name = str2;
typedef __nullterminated CONST WCHAR *LPCWSTR, *PCWSTR;
typedef wchar_t WCHAR;
QString--->wchar_t*--->WCHAR*--->CONST WCHAR*--->LPCWSTR
简略写:
QString--->wchar_t*--->LPCWSTR
参考: