相关文章
1、QString::fromLocal8Bit()函数----https://blog.csdn.net/weixin_43614380/article/details/106674434
//==========================PC上的Qt如下======================
QSqlQuery query(g_db);
QString qstr_query=QString("select * from xxxx where yyy=%1").arg(zzz);
query.exec(qstr_query);
QString qstr_name=query.value(name_index).toString();
QByteArray ba=qstr_name.toLatin1();
QString hzstr=QString::fromLocal8Bit(ba.data(),strlen(ba.data()));
ui->lineEdit_name->setText(hzstr);
//==========================嵌入式上的Qt如下======================
QSqlQuery query(g_db);
QString qstr_query=QString("select * from xxxx where yyy=%1").arg(zzz);
query.exec(qstr_query);
QString qstr_name=query.value(name_index).toString();
QByteArray ba=qstr_name.toLatin1();
QTextCodec * codec = QTextCodec::codecForName ("GBK");
ui->lineEdit_name->setText(codec->toUnicode(ba));