qstring与众多的字符串(写壳时找的点资料)

qstring is unicode. utf16 in qt4.

QString fromAscii ( const char * str, int size = -1 )
QString fromLatin1 ( const char * str, int size = -1 )
QString fromLocal8Bit ( const char * str, int size = -1 )
QString fromRawData ( const QChar * unicode, int size )
QString fromStdString ( const std::string & str )
QString fromStdWString ( const std::wstring & str )
QString fromUcs4 ( const uint * unicode, int size = -1 )
QString fromUtf8 ( const char * str, int size = -1 )
QString fromUtf16 ( const ushort * unicode, int size = -1 )
QString fromWCharArray ( const wchar_t * string, int size = -1 )


qstring ->std::string
qstring::toStdString () ,qstring::toStdWString ()

BSTR<->qstring
BSTR bstr_str;
qstring q_str((QChar*)bstr_str, wcslen(bstr_str))
bstr_str = SysAllocString(q_str.utf16())

remember use SysFreeString on BSTR

qstring<->LPCSTR
qstring::toLocal8Bit().constData()
QString fromLocal8Bit ( const char * str, int size = -1 )

qstring<->LPCWSTR
qstring::utf16()
QString fromUtf16 ( const ushort * unicode, int size = -1 )

qstring<->CString
CString c_str(qstring::utf16())
QString fromUtf16 (LPCTSTR(c_str) )

你可能感兴趣的:(String)