QFile f( "c:\\a.txt");
if(! f.open( QIODevice::ReadWrite | QIODevice::Append | QIODevice::Text))
{
return ;
}
QTextStream out( &f);
out.seek(0); //以QIODevice::Append方式打开文件,文件指针将会自动到文件尾
QString str = out.readLine();
本文展示了一个使用Qt进行文件操作的简单示例,包括以追加模式打开文件、使用QTextStream读取第一行文本等内容。
QFile f( "c:\\a.txt");
if(! f.open( QIODevice::ReadWrite | QIODevice::Append | QIODevice::Text))
{
return ;
}
QTextStream out( &f);
out.seek(0); //以QIODevice::Append方式打开文件,文件指针将会自动到文件尾
QString str = out.readLine();
390

被折叠的 条评论
为什么被折叠?