Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

Regarding using QFile::readAll



  • Hi All

    Is it a good idea to read the complete file using QFile::readAll and store in QString variable.



  • It heavily depends on your use case, the size of the file, the amount of memory available - and probably many other parameters. But in general it is perfectly legitimate to read files as a whole.

    Yes, it can be a good idea to read a whole file using QFile::readAll().
    No, it can be a bad idea to read a whole file using QFile::readAll().



  • Which kind of question is that? It's not a matter of one-size-fits-all rules. If it makes sense for you (esp. regarding the memory allocation of such a thing) then do it. Just remember to properly decode the bytes of the file.


Log in to reply