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;
            }
        }spa

   ...stream

相關文章
相關標籤/搜索