qt中文格式GBK.UTF-8,unicode 之间的转换

QTextCodec *gbk = QTextCodec::codecForName("GB18030");
QTextCodec *utf8 = QTextCodec::codecForName("UTF-8");
QString g2u = gbk->toUnicode(m_pUserSpi.m_mapInstruments.find(str1.toStdString())->second->InstrumentName);

QString as = g2u.toUtf8();


头两句是格式。第三句,把括号内查询到的GBK值转成Unicode,第四句把Unicode转成utf-8.

##utf转gbk步骤反过来就行了。