QTextStream 读取文件乱码的解决办法

通常都是编码转换的问题,注意如以下红字代码那样设置正确的编码

QFile _file(_f_path);
    try{
        if(_file.open(QIODevice::ReadOnly))
        {
            QTextStream _txt_stream(&_file);
            _txt_stream.setCodec("UTF-8");//处理utf8中文
            while(!_txt_stream.atEnd()){
                _recent_txt = _txt_stream.readLine();
                qDebug()<<_recent_txt;
            }
        }

   ...

原文地址:https://www.cnblogs.com/falqs/p/3952455.html