QTextStream readAll issue
-
Hi,
Does anyone else have issues with QTextStream::readAll in Qt 6.5.2 (on MSCV) ?
It seems to be stuck when I try to read a 180mb file, which doesn't happen in Qt 5.15.2.
It also seems to be significantly slower in general than in Qt 5.
A 20mb file which is read almost instantly in Qt5 takes 4-5 seconds in the Qt 6 build.It seems like these two issues may be intertwined.
Maybe the read time is simply increased exponentially with the file size.This somehow reminds me of the hilarous GTA5 online bug from a while back that unnecessarily caused ridiculous loading times for years.
Here a minimal snippet.
if (QFile file(path); file.exists() && file.open(QIODevice::ReadOnly | QIODevice::Text)) { QTextStream stream(&file); QString content = stream.readAll(); // Gets stuck on 180mb file //QString content = file.readAll(); // Workaround file.close(); }
-
@Megamouse for such big files I recommend using the stream part of QTextStream and read file in chunks :D It really gives amazing performance improvement, regardless of which Qt version you are using. It will lower both CPU and RAM usage by a lot. Talking from experience here :-)
Regarding the slowness issue: this sounds like something Qt devs should look into. Please consider reporting it on Qt bugtracker!