在QT中生成期间获取文件大小
Get file size during generate in QT
我需要在生成文件时获取文件大小。
我试过使用 QThread 和 QFileInfo::size
以及带有标志的 while
,当完成文件时发出信号,但值永远不会改变。
所以想知道您是否可以在生成文件时获取文件大小。
来自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).
所以在(重新)检查文件大小之前尝试 QFileInfo::refresh()
功能。
我需要在生成文件时获取文件大小。
我试过使用 QThread 和 QFileInfo::size
以及带有标志的 while
,当完成文件时发出信号,但值永远不会改变。
所以想知道您是否可以在生成文件时获取文件大小。
来自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).
所以在(重新)检查文件大小之前尝试 QFileInfo::refresh()
功能。