سؤال

Hi all I want to use QFileSystemWatcher to watch changes of a given directory and its subdirectory recursively, but void QFileSystemWatcher::addPath ( const QString & path ) didn't let me do it so is there any idea to do it easily or I should implement it by my self (extract all directories and subdirectories and files under to added with void QFileSystemWatcher::addPaths ( const QStringList & paths ))?

Any help will be appreciated.

Thank you in advance.

هل كانت مفيدة؟

المحلول

The documentation of class QFileSystemWatcher doesn't state that recursive watching is part of its contract. So I think a solution might be, as you hinted, to walk the directory tree yourself, gather all sub-directories and their files in a string list and use

void QFileSystemWatcher::addPaths ( const QStringList & paths )

Also, I think it might be useful for you to mention which version of qt you are working with, because according to this thread, QFileSystemWatcher is being deprecated and a new api is supposed to replace it.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top