string -> QString

1 std::string strStd ="可可西";
2 QString strQ = QString::fromLocal8Bit(strStd.c_str());

QString -> string

 

1 QString strQ("可可西");
2 std::string strStd= strQ.toStdString();
3 QTextCodec *code = QTextCodec::codecForName("gb18030");
4 // 如果code为0,表示在运行的机器上没有装gb18030字符集。不过一般的中文windows系统中都安装了这一字符集
5 if (code)
strStd= code->fromUnicode(strQ).data();

 

来自:http://www.cnblogs.com/kekec/archive/2011/06/03/2070504.html

posted on 2012-05-27 01:49  娜美fresh  阅读(2818)  评论(0编辑  收藏  举报