前言:Xml文件中包含中文和中文字符,显示乱码在QLineEdit控件上
解决:
QFile f(filePath);
if (!f.open(QFile::ReadOnly | QFile::Text))
{
return false;
}
QTextStream stream(&f);
QTextCodec *codec = QTextCodec::codecForName("UTF-8");
stream.setCodec(codec);
QString content = stream.readAll();