String 转 QString:
QTextCodec::setCodecForLocale(QTextCodec::codecForName("GBK"));//添加设置本地GBK
QString qstr=QString::fromLocal8Bit(str.c_str());
QString 转 String:
QString qstr=ui.destination_line->text();//从edit——line中获取文本
string str= qstr.toStdString();
QTextCodec *code = QTextCodec::codecForName("gb18030");
str= code->fromUnicode(qstr).data();
参考: