Results 1 to 7 of 7

Thread: QFileSystemWatcher no fileChanged signal

  1. #1
    Join Date
    Dec 2008
    Location
    Poland
    Posts
    383
    Thanks
    52
    Thanked 42 Times in 42 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Android

    Default QFileSystemWatcher no fileChanged signal

    Hello,
    I have QFileSystemWatcher and problem with it.
    Signal fileChanged(QString) is never emited, but directoryChanged(QString) is emited.
    The list of files fileWatcher->files() is empty.
    I added path with file count less then 256, there is like 5files.

    Any idea why is that happening? QFileSystemWatcher->directories() list all directories that I added and there is no error.

    Platform Windows.
    Thanks for reply.
    In the near future - corporate networks reach out to the stars. Electrons and light flow throughout the universe.
    The advance of computerization however, has not yet wiped out nations and ethnic groups.

  2. #2
    Join Date
    Mar 2008
    Location
    Kraków, Poland
    Posts
    1,536
    Thanked 284 Times in 279 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QFileSystemWatcher no fileChanged signal

    I have any problems with QFileSystemWatcher. Show some code.

  3. The following user says thank you to Lesiok for this useful post:

    Talei (18th December 2011)

  4. #3
    Join Date
    Dec 2008
    Location
    Poland
    Posts
    383
    Thanks
    52
    Thanked 42 Times in 42 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Android

    Default Re: QFileSystemWatcher no fileChanged signal

    Qt Code:
    1. someClass::someClass(){ // <- constructor
    2. fw = new QFileSystemWatcher( this );
    3. connect( fw, SIGNAL(fileChanged(QString)), this, SLOT( fileChangedSlot(QString)) ); // <- never emit
    4. // connect( fw, SIGNAL(directoryChanged(QString)), this, SLOT( fileChangedSlot(QString)) ); //emit but files() is empty, directories() is ok, I can see d:/test
    5.  
    6. fw->addPath( "D:/test" );
    7. qDebug() << fw->files() << fw->directories(); // outputs: () ("D:/test") in test ther are file
    8.  
    9.  
    10. }
    11.  
    12. void someClass::fileChangedSlot(QString fileName)
    13. {
    14. #ifdef QT_DEBUG
    15. qDebug() << "files watched: " << fw->files() << fw->directories();
    16. #endif
    17.  
    18. }
    To copy to clipboard, switch view to plain text mode 

    if I delete test directory, then:
    Qt Code:
    1. QFileSystemWatcher: FindNextChangeNotification failed!! (Access is denied.)
    To copy to clipboard, switch view to plain text mode 

    So QFileSystemWatcher don't add files in that directory to "watch list" (there is 6files)
    I have no idea why is that happening, I even changed parent for this obj. without any help.
    In the near future - corporate networks reach out to the stars. Electrons and light flow throughout the universe.
    The advance of computerization however, has not yet wiped out nations and ethnic groups.

  5. #4
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    4,380
    Thanks
    19
    Thanked 1,005 Times in 913 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60
    Wiki edits
    5

    Default Re: QFileSystemWatcher no fileChanged signal

    the file change signal is emited when you change the name of the directory. And the files() are empty because you only have added a path to watch... You will be notified about file changes inside that directory through directoryChanged(). Note the argument!

    ... and the QT_DEBUG madness ...

  6. The following user says thank you to Lykurg for this useful post:

    Talei (18th December 2011)

  7. #5
    Join Date
    Dec 2008
    Location
    Poland
    Posts
    383
    Thanks
    52
    Thanked 42 Times in 42 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Android

    Default Re: QFileSystemWatcher no fileChanged signal

    I don't know why but I thought that addPath() will scan directory and add all files in that dir. ...

    Everything works fine, as always user mistake with Qt usage.

    Btw. why QT_DEBUG madness? I don't want qDebug() I release.
    In the near future - corporate networks reach out to the stars. Electrons and light flow throughout the universe.
    The advance of computerization however, has not yet wiped out nations and ethnic groups.

  8. #6
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    4,380
    Thanks
    19
    Thanked 1,005 Times in 913 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60
    Wiki edits
    5

    Default Re: QFileSystemWatcher no fileChanged signal

    Quote Originally Posted by Talei View Post
    I don't want qDebug() I release.
    Everyone want that, so Qt is taking care that the debug message is suppressed in release mode. Even if they have change the default behavior, you can simply define QT_NO_DEBUG_OUTPUT in your pro file as well as QT_NO_WARNING_OUTPUT to mute them. No need to enclose all calls with a preprocessor statement.

  9. The following user says thank you to Lykurg for this useful post:

    Talei (18th December 2011)

  10. #7
    Join Date
    Dec 2008
    Location
    Poland
    Posts
    383
    Thanks
    52
    Thanked 42 Times in 42 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Android

    Default Re: QFileSystemWatcher no fileChanged signal

    I didn't know that QT_NO_DEBUG_OUTPUT will remove qDebug() line.
    Thanks again.
    In the near future - corporate networks reach out to the stars. Electrons and light flow throughout the universe.
    The advance of computerization however, has not yet wiped out nations and ethnic groups.

Similar Threads

  1. QFilesystemWatcher fileChanged events
    By rhblind in forum Newbie
    Replies: 0
    Last Post: 17th August 2011, 10:19
  2. QFIleSystemWatcher
    By jayreddy in forum Qt Programming
    Replies: 1
    Last Post: 15th December 2009, 08:21
  3. QFileSystemWatcher fileChanged signal doubling
    By roxton in forum Qt Programming
    Replies: 6
    Last Post: 16th May 2008, 13:01
  4. QFileSystemWatcher
    By Kumosan in forum Qt Programming
    Replies: 2
    Last Post: 18th March 2008, 20:52
  5. Need help with QFileSystemWatcher
    By L.Marvell in forum Qt Programming
    Replies: 1
    Last Post: 18th August 2006, 13:19

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.