QStringList lines;
QFile file( "file.txt" );
if ( file.open( IO_ReadOnly ) ) {
QTextStream stream( &file );
QString line;
int n = 1;
while ( !stream.eof() ) {
line = stream.readLine(); // 不包括“\n”的一行文本
printf( "第%3d行内容: %s\n", n++, line.latin1() );
lines += line;
}
file.close();
}