我从qt4文档中找到关于读取文件的例子
QStringList lines;
QFile file( "file.txt" );
if ( file.open( IO_ReadOnly ) ) {
QTextStream stream( &file );
QString line;
int i = 1;
while ( !stream.atEnd() ) {
line = stream.readLine(); // line of text excluding '\n'
printf( "%3d: %s\n", i++, line.latin1() );
lines += line;
}
file.close();
}
但是我make 出错,我安装的是qt4.4.1
alsa.cpp:269: error: `IO_ReadOnly' undeclared (first use this function)
alsa.cpp:269: error: (Each undeclared identifier is reported only once for each
function it appears in.)
alsa.cpp:275: error: 'class QString' has no member named 'latin1'
IO_ReadOnly和latin1都在文档中有 不是自己定义的 ,
望高手帮助