qt读取中文txt文件
2014-06-12 20:57
573 查看
QAbstractItemModel *Widget::modelFromFile(const QString& fileName)
{
QFile file(fileName);
// qDebug()<<"aa";
// qDebug()<<file.open(QFile::ReadOnly);
if (!file.open(QFile::ReadOnly))
return new QStringListModel(completer);
// qDebug()<<"aa";
#ifndef QT_NO_CURSOR
QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
#endif
QStringList words;
QTextStream stream( &file );
QString line;
// qDebug()<<"aa";
// qDebug()<<!stream.atEnd();
while ( !stream.atEnd() )
{
// qDebug()<<!stream.atEnd();
line = stream.readLine(); // 不包括“\n”的一行文本
// qDebug()<<line;
words.append(line.trimmed());
}
file.close();
// qDebug()<<words.size();
//}
qDebug()<<words.at(0)<<words.at(1)<<words.at(2)<<words.at(3)<<words.at(4)<<words.at(5);
#ifndef QT_NO_CURSOR
QApplication::restoreOverrideCursor();
#endif
return new QStringListModel(words, completer);
}
//! [2]
记录一下
相关文章推荐
- QT读取TXT文件显示中文
- QT读取TXT文件显示中文
- asp.net 按行读取包含中文的文本(txt)文件并取得行数
- qt读取中文文件内容的测试
- FileReader读取中文txt文件编码丢失问题
- qt读取中文文件的测试
- StreamReader无法读取中文命名的Txt文件
- QT读写TXT文件显示中文
- C#中读取txt文件中的中文时出现乱码问题
- 从ANSI编码格式txt文件中读取中文
- QT 读取txt 文件
- QT读取中文文件
- QT读取中文文件
- 【JAVA】读取txt文件中文乱码问题
- android读取txt文件中文乱码的问题
- java学习笔记_将中文字符导出txt文档_从txt文档读取文件
- Andoird - 解决读取txt文件中文乱码问题
- QT读取中文文件(转)
- asp.net 按行读取包含中文的文本(txt)文件并取得行数
- qt5解决读取ini文件中中文乱码