I'm using QFileSystemWatcher for watching for changes in a directory that I set in watcher->addPath("myPath") method.
When I call watcher->directories() I see myPath.
But when I call watcher->files() I see nothing. I thought I will see files in directory when I use this method.
What should I do to see files in a directory?
QFileSystemWatcher is intended to watch changes in the file system.
To obtain a list of files in a directory use QDir::entryList.
Example:
QString files = QDir("c:\\").entryList(QDir::NoDotAndDotDot);
If you need to watch changes in a directory (file added/renamed or removed events) you use addPath with a directory and listen to directoryChanged signal.
If you need to watch a file content change you use addPath with a full path to a file and listen to fileChanged signal.
Accordingly directories returns a list of directories you have added and files returns a list of files you have added.