PDA

View Full Version : Problem with QFileSystemWatcher?



arbi
25th February 2009, 14:10
Hi ,

i am using QFileSystemWatcher to monitor some set of user defined folders. whenever a new file added into those folders i want to process those new files.

It seems that QFileSystemWatcher does not monitor the inner subfolders , which i want to achieve. Adding all of the folders in a given folder to the watchList seperately seems very ineffective and hard way of doing this, (especially updating myWatchList in case of adding a large folder into my already-monitored folders)

Is there any way of making this class to monitor folders recursively (including subfolders.)

thanks..

talk2amulya
25th February 2009, 15:01
well, as the documentation says, there is no way for u to monitor even the subfolders. but there is always a workaround in QT, so here is how u can easily create a stringlist of the sub-folders inside a folder: use the following function


QStringList subFoldersList(QString folder)
{
QDir dir(folder);
dir.setFilter(QDir::Dirs);

QFileInfoList list = dir.entryInfoList();
QStringList dirList;

for (int i = 0; i < list.size(); ++i) {
QFileInfo fileInfo = list.at(i);
dirList << fileInfo.fileName();
}

return dirList;
}

this way u can get the stringlist of subfolders and then u can use addPaths() easily

Arifa
4th February 2011, 05:56
I get these errors when I use the above code:
QInotifyFileSystemWatcherEngine::addPaths: inotify_add_watch failed: No such file or directory
can u please let me know the solution if any

Surendil
29th March 2012, 07:57
Maybe you try to add "." or ".."?