简体   繁体   中英

Why does QFile::canReadLine() always return false?

I was trying to read a file line by line using

while (file.canReadLine()) {
    QString line = QString::fromUtf8(file.readLine());
    qDebug() << line;
}

but QFile::canReadLine() always returns false, even though file.readLine() succeeds and reads the next line each time it's called (I've tested that).

Is it supposed always return false? The docs say that it always returns false for unbuffered devices , but isn't QFile buffered?

I'm using Qt 4.7.4.

It appears that this is not the expected behavior . It is a bug, and it has already been reported .

It affects Qt versions 4.7.4, 4.8.0, 4.8.1, 4.8.2.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM