Qt有没有提供接口,可以监控文件夹内容的变化?

bndxgae 2010-05-27 04:33:10
请问,Qt有没有提供这类的接口,可以监控文件夹内容的变化?
...全文
504 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
donwmufromdying 2010-05-28
  • 打赏
  • 举报
回复
Detailed Description

The QFileSystemWatcher class provides an interface for monitoring files and directories for modifications.

QFileSystemWatcher monitors the file system for changes to files and directories by watching a list of specified paths.

Call addPath() to watch a particular file or directory. Multiple paths can be added using the addPaths() function. Existing paths can be removed by using the removePath() and removePaths() functions.

QFileSystemWatcher examines each path added to it. Files that have been added to the QFileSystemWatcher can be accessed using the files() function, and directories using the directories() function.

The fileChanged() signal is emitted when a file has been modified, renamed or removed from disk. Similarly, the directoryChanged() signal is emitted when a directory or its contents is modified or removed. Note that QFileSystemWatcher stops monitoring files once they have been renamed or removed from disk, and directories once they have been removed from disk.

Note: On systems running a Linux kernel without inotify support, file systems that contain watched paths cannot be unmounted.

Note: Windows CE does not support directory monitoring by default as this depends on the file system driver installed.

Note: The act of monitoring files and directories for modifications consumes system resources. This implies there is a limit to the number of files and directories your process can monitor simultaneously. On Mac OS X 10.4 and all BSD variants, for example, an open file descriptor is required for each monitored file. Some system limits the number of open file descriptors to 256 by default. This means that addPath() and addPaths() will fail if your process tries to add more than 256 files or directories to the file system monitor. Also note that your process may have other file descriptors open in addition to the ones for files being monitored, and these other open descriptors also count in the total. Mac OS X 10.5 and up use a different backend and do not suffer from this issue.

See also QFile and QDir.

donwmufromdying 2010-05-28
  • 打赏
  • 举报
回复
QFileSystemWatcher,就是这个!
donwmufromdying 2010-05-28
  • 打赏
  • 举报
回复
有! 是一个signal.长久不用,忘记了。我找找
上善若水邻 2010-05-28
  • 打赏
  • 举报
回复
[Quote=引用 2 楼 prochsh 的回复:]
找找看有没有显示文件夹修改时间的函数。。。
[/Quote]
同意
信念 2010-05-27
  • 打赏
  • 举报
回复
找找看有没有显示文件夹修改时间的函数。。。
gemfield 2010-05-27
  • 打赏
  • 举报
回复
QDir类提供了一些方法可以, entryList(), entryInfoList(),count()之类的.

16,215

社区成员

发帖
与我相关
我的任务
社区描述
Qt 是一个跨平台应用程序框架。通过使用 Qt,您可以一次性开发应用程序和用户界面,然后将其部署到多个桌面和嵌入式操作系统,而无需重复编写源代码。
社区管理员
  • Qt
  • 亭台六七座
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧