Home · All Classes · Modules

QFileSystemWatcher Class Reference
[QtCore module]

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

Inherits QObject.

Methods

Qt Signals


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 or removed from disk. Similarly, the directoryChanged() signal is emitted when a directory is modified or removed. Note that QFileSystemWatcher stops monitoring files and directories once they have been removed from disk.

See also QFile and QDir.


Method Documentation

QFileSystemWatcher.__init__ (self, QObject parent = None)

The parent argument, if not None, causes self to be owned by Qt instead of PyQt.

Constructs a new file system watcher object with the given parent.

QFileSystemWatcher.__init__ (self, QStringList paths, QObject parent = None)

The parent argument, if not None, causes self to be owned by Qt instead of PyQt.

Constructs a new file system watcher object with the given parent which monitors the specified paths list.

QFileSystemWatcher.addPath (self, QString file)

Adds path to the file system watcher if path exists. The path is not added if it does not exist, or if it is already being monitored by the file system watcher.

If path specifies a directory, the directoryChanged() signal will be emitted when path is modified or removed from disk; otherwise the fileChanged() signal is emitted when path is modified or removed.

See also addPaths() and removePath().

QFileSystemWatcher.addPaths (self, QStringList files)

Adds each path in paths to the file system watcher. Paths are not added if they not exist, or if they are already being monitored by the file system watcher.

If a path specifies a directory, the 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 or removed.

See also addPath() and removePaths().

QStringList QFileSystemWatcher.directories (self)

Returns a list of paths to directories that are being watched.

See also files().

QStringList QFileSystemWatcher.files (self)

Returns a list of paths to files that are being watched.

See also directories().

QFileSystemWatcher.removePath (self, QString file)

Removes the specified path from the file system watcher.

See also removePaths() and addPath().

QFileSystemWatcher.removePaths (self, QStringList files)

Removes the specified paths from the file system watcher.

See also removePath() and addPaths().


Qt Signal Documentation

void directoryChanged (const QString&)

This signal is emitted when the directory at the specified path is modified or removed from disk. Note that if there are several changes during a short period of time, some of the changes might not emit this signal. However, the last change in the sequence of changes will always generate this signal.

See also fileChanged().

void fileChanged (const QString&)

This signal is emitted when the file at the specified path is modified or removed from disk.

See also directoryChanged().


PyQt 4.3.1 for X11Copyright © Riverbank Computing Ltd and Trolltech AS 2007Qt 4.3.0