内容表

上一话题

QFileSelector

下一话题

QFinalState

QFileSystemWatcher

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

Inheritance diagram of PySide2.QtCore.QFileSystemWatcher

概要

函数

详细描述

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

调用 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() 函数。

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() 函数。

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.

另请参阅

QFile QDir

class QFileSystemWatcher ( [ parent=None ] )

QFileSystemWatcher(paths[, parent=None])

param parent

QObject

param paths

字符串列表

构造新的文件系统看守程序对象采用给定 parent .

构造新的文件系统看守程序对象采用给定 parent which monitors the specified paths 列表。

PySide2.QtCore.QFileSystemWatcher. addPath ( file )
参数

file – unicode

返回类型

bool

添加 path 到文件系统看守程序若 path 存在。路径不被添加若路径不存在 (或路径已被文件系统看守程序所监视)。

path 指定目录, directoryChanged() signal will be emitted when path 被修改或从磁盘被移除;否则 fileChanged() signal is emitted when path 被修改、被重命名或被移除。

若看守成功,返回 true。

看守失败的原因通常从属系统,但可能包括:资源不存在、访问失败或总看守计数限制 (若平台有限制的话)。

注意

There may be a system dependent limit to the number of files and directories that can be monitored simultaneously. If this limit is been reached, path will not be monitored, and false is returned.

PySide2.QtCore.QFileSystemWatcher. addPaths ( 文件 )
参数

文件 – 字符串列表

返回类型

字符串列表

添加每个路径在 paths 到文件系统看守程序。路径不被添加若路径不存在 (或路径已被文件系统看守程序所监视)。

若路径指定目录, directoryChanged() signal will be emitted when the path is modified or removed from disk; otherwise the fileChanged() signal is emitted when the path is modified, renamed, or removed.

返回值是无法看守的路径的列表。

看守失败的原因通常从属系统,但可能包括:资源不存在、访问失败或总看守计数限制 (若平台有限制的话)。

注意

There may be a system dependent limit to the number of files and directories that can be monitored simultaneously. If this limit has been reached, the excess paths will not be monitored, and they will be added to the returned QStringList .

PySide2.QtCore.QFileSystemWatcher. directories ( )
返回类型

字符串列表

返回正被看守的目录路径列表。

另请参阅

files()

PySide2.QtCore.QFileSystemWatcher. 文件 ( )
返回类型

字符串列表

返回正被看守的文件路径列表。

另请参阅

directories()

PySide2.QtCore.QFileSystemWatcher. removePath ( file )
参数

file – unicode

返回类型

bool

移除指定 path 从文件系统看守程序。

若看守被成功移除,返回 true。

移除看守失败的原因通常从属系统 (如:可能由于路径已被删除)。

PySide2.QtCore.QFileSystemWatcher. removePaths ( 文件 )
参数

文件 – 字符串列表

返回类型

字符串列表

移除指定 paths 从文件系统看守程序。

返回值是不能成功取消看守的路径的列表。

移除看守失败的原因通常从属系统 (如:可能由于路径已被删除)。