Results 1 to 4 of 4

Thread: Problem with QFileSystemWatcher?

  1. #1
    Join Date
    Aug 2008
    Posts
    27
    Thanks
    3
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Problem with QFileSystemWatcher?

    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..

  2. #2
    Join Date
    Feb 2009
    Location
    Noida, India
    Posts
    517
    Thanks
    21
    Thanked 66 Times in 62 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Problem with QFileSystemWatcher?

    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

    Qt Code:
    1. QStringList subFoldersList(QString folder)
    2. {
    3. QDir dir(folder);
    4. dir.setFilter(QDir::Dirs);
    5.  
    6. QFileInfoList list = dir.entryInfoList();
    7. QStringList dirList;
    8.  
    9. for (int i = 0; i < list.size(); ++i) {
    10. QFileInfo fileInfo = list.at(i);
    11. dirList << fileInfo.fileName();
    12. }
    13.  
    14. return dirList;
    15. }
    To copy to clipboard, switch view to plain text mode 

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

  3. #3
    Join Date
    Aug 2010
    Location
    India
    Posts
    7
    Qt products
    Qt4
    Platforms
    Unix/X11 Maemo/MeeGo

    Default Re: Problem with QFileSystemWatcher?

    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

  4. #4
    Join Date
    Mar 2012
    Location
    Tver, Russia
    Posts
    9
    Thanks
    1
    Thanked 3 Times in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60

    Default Re: Problem with QFileSystemWatcher?

    Maybe you try to add "." or ".."?

Similar Threads

  1. deployment problem: msvc++ 2008 Express, Qt 4.4.3
    By vonCZ in forum Qt Programming
    Replies: 7
    Last Post: 10th November 2008, 14:38
  2. Weird problem: multithread QT app kills my linux
    By Ishark in forum Qt Programming
    Replies: 2
    Last Post: 8th August 2008, 09:12
  3. Steps in solving a programming problem?
    By triperzonak in forum General Programming
    Replies: 8
    Last Post: 5th August 2008, 08:47
  4. QFileSystemWatcher problem!!
    By Raajesh in forum Qt Programming
    Replies: 0
    Last Post: 23rd June 2008, 17:46
  5. Replies: 16
    Last Post: 7th March 2006, 15:57

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.