Get file size during generate in QT

992 Views Asked by At

I need get the File size while it is being generated.

I've tried using QThread and QFileInfo::size and a while with a flag that signals when the finished file, but the value never changes.

So was wondering if you can take the file size while it is being generated.

1

There are 1 best solutions below

1
On BEST ANSWER

From the Qt docs:

Note: To speed up performance, QFileInfo caches information about the file. Because files can be changed by other users or programs, or even by other parts of the same program, there is a function that refreshes the file information: refresh(). If you want to switch off a QFileInfo's caching and force it to access the file system every time you request information from it call setCaching(false).

So try the QFileInfo::refresh() function before (re-)checking the file size.