逐行读取
QFile file("/home/administrator/testdir/test.txt"); if(!file.open(QIODevice::ReadOnly | QIODevice::Text)) { qDebug()<<"Can't open the file!"<} while(!file.atEnd()) { QByteArray line = file.readLine(); QString str(line); qDebug()<< str; }