QT最常用的字符串操作
1. BSTR 转 QString
//bstr is a BSTR QString qstr = QString::fromUtf16(reinterpret_cast<ushort*>(bstr));
2. QString 转 const wchar_t*
const wchar_t* buf = reinterpret_cast<const wchar_t *>(qstr.utf16());
或者
const wchar_t* buf = qstr.toStdWString().c_str();
3. QString 取后面的字串
QString qstr = "QT@Joshua"; int index = qstr.lastIndexOf("@"); qstr = qstr.mid(index + 1); qDebug()<<qstr;//we got "Joshua"