直接 代码:
1 // lyy : 2016/8/26 16:40:11 说明:读取文本 2 bool FileOpeartion:: GetTheTextContent (const QString strPath, QStringList &strContent) 3 { 4 QFile file (strPath); 5 6 if (file.open (QIODevice::ReadOnly | QIODevice::Text)) 7 { 8 QTextStream in (&file); 9 //in.setCodec (QTextCodec::codecForName ("GB2312")); 10 QString line; 11 12 while (!in.atEnd()) 13 { 14 line = in.readLine(); 15 16 if (!line.isNull() && !line.isEmpty()) 17 { 18 strContent << line; 19 } 20 } 21 22 file.close(); 23 } 24 25 return true; 26 }