QTextCodec *gbk = QTextCodec::codecForName("gb18030"); QTextCodec *utf8 = QTextCodec::codecForName("utf-8"); QTextCodec::setCodecForTr(gbk); QTextCodec::setCodecForLocale(gbk); // QString utfStr = QObject::trUtf8( tr("webservice 读取完成").toUtf8()); //utf-8 QString utfStr = QObject::trUtf8(pp); //utf-8 // QString gbkStr = QObject::tr("中文"); // gbk QString utf2gbk = gbk->toUnicode(utfStr.toLocal8Bit()); // utf8 conver gbk // qDebug() << utf2gbk; gloinfo = utf2gbk; qDebug() << gloinfo; // QString gbk2utf1 = utf8->toUnicode(utf2gbk.toUtf8()); // gbk convert utf8 // QString g2u = gbk->toUnicode(gbk->fromUnicode(readStr)); // gbk convert utf8