It's used exactly for that purpose -- storing large amounts of temporary data which doesn't need super-low access times (so there's no need to waste RAM). You can do whatever you like with that data, just don't close the file. And, to be honest, I don't see any [good] reason to close a temporary file (regardless of the implementation) if you're going to access it again, particularly for the reason mentioned by Thiago -- closing a file means losing any control over its contents, there are absolutely no guarantees that the next time you open the "same" file (when actually that'll be a file with the same path), you'll see the same data you wrote to it earlier. On Sep 26, 2013 12:57 PM, "Etienne Sandré-Chardonnal" < etienne.san...@m4x.org> wrote:
> Hi Thiago, > > Then I don't see the point of QTemporaryFile... You write some data and > can't do anything with it? > > What are the legacy uses of it? > - Open the file with a QFile for reading. Such use would be a large > buffer we do not want to keep in memory. But according to what you said, it > must be done before the QTemporaryFile was closed. Then, what guarantees > the writes have been flushed? > - Write data to a temporary file before renaming it to the final name. > This is useful when a user saves a document overwriting the old version, in > case the system or app crashes he does not loose all the work. But > QFile::rename() closes before renaming, which means according to what you > said the data is not guaranteed to be still there. > > I definitely need some additionnal explanation to the documentation on how > to use this class > > Etienne > > > 2013/9/26 Thiago Macieira <thiago.macie...@intel.com> > >> Once you close the file, your data is gone. Your data only exists as long >> as >> you keep the file open. >> > > _______________________________________________ > Interest mailing list > Interest@qt-project.org > http://lists.qt-project.org/mailman/listinfo/interest > >
_______________________________________________ Interest mailing list Interest@qt-project.org http://lists.qt-project.org/mailman/listinfo/interest