if (!file.open(QIODevice::ReadOnly | QIODevice::Text))
return
QTextStream in(&file)
QString line = in.readLine()
你可以试试
逐行读取
QFile file("/home/administrator/testdir/test.txt")if(!file.open(QIODevice::ReadOnly | QIODevice::Text)) {
qDebug()<<"Can't open the file!"<<endl
}
while(!file.atEnd()) {
QByteArray line = file.readLine()
QString str(line)
qDebug()<< str
}
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)