As pointed out, there is no such constructor for QTextStream
.
I quickly typed those few lines to verify it is indeed working properly:
foreach (QString file, files) {
QFile f(file);
if (!f.open(QFile::ReadOnly | QFile::Text)) break;
QTextStream in(&f);
qDebug() << f.size() << in.readAll();
}
And I do get the expected output – the size and content of each file. Try that code to check if you mistyped anything.
At this point I am pretty sure the problem is in your fileList
– you don’t check if QFile::open()
succeeds and continue. Ironically, if open()
fails and your code continues, you will get exactly 0 for the file size, and exactly an empty string for the result of readAll()
. So the problem lies with your file names. And next time check if open()
succeeds – not doing so is a very bad practice.
Another possible candidate for your files failing to open is if they are open for writing by some other process. Reboot your system and run your code directly to make sure the file access is not locked.
If that doesn’t help too, head over to the Qt project website to post the problem there, and if necessary – a bug report.