QFileSystemWatcher not sending signal when monitored folder itself deleted.
-
@QFileSystemWatcher *watch_files = new QFileSystemWatcher;
connect(watch_files, SIGNAL(directoryChanged(QString)), this, SLOT(research_folders()));@Video reproducing this problem:
"http://www.youtube.com/watch?v=1IyjO6-osGU":http://www.youtube.com/watch?v=1IyjO6-osGUWhat can i do for this?
-
Have you initialized the path?
@ watcher->addPath("/usr/name/jadajada"); @see "this":http://www.voslov.com/c++/qt/showPage.php?ID=281&SAMPLEID=QFileSystemWatcherDetectDirandFileChange
-
Didn't u saw the video?
u can see that the path is added to the QFileSystemWatcher (renaming or deleting an image inside the folder will send a signal directoryChanged)
yes i am using watcher->addPath(path);
The problem is when deleting the monitored folder itself
[quote author="broadpeak" date="1359721966"]Have you initialized the path?
@ watcher->addPath("/usr/name/jadajada"); @ -
OFF:
Anyway, I'm a great TheCardigans fan too
and its No Sleep song is one of my favourite :)
ON:Sorry, but the code is hardly seen...
So:
What I have code linked, that is working on my machine (Win7, Qt 4.8.3).
Try that code in your machine too. Can be a Qt bug... -
ON
I dont want you to see any code from the video, as said in 1st post the code is simple:
@QFileSystemWatcher *watch_files = new QFileSystemWatcher;
connect(watch_files, SIGNAL(directoryChanged(QString)), this, SLOT(research_folders()));@And when you click on my program the Browze button, then select the folder the code is:
@watch_files->addPath(path);@And it doesn't work when u delete the folder ^^ :/
OFF
I am digging threw my fathers music alphabetically, and i have stopped in cardigans folder 2 weeks now
I love all of their songs without an exception ;) -
Looks to me like you should connect to the fileChanged signal too. The documentation for directoryChanged only talks about changes to the content of the directory, like a file in that directory being added, renamed or removed. However, the documentation for fileChanged talk about changes to the changes to the monitored path itself. I bet directoryChanged also doesn't fire when you change the name of the directory you're monitoring.
I do admit that the docs can use a bit more clarity here, but this is what I read from it.
-
[quote author="broadpeak" date="1359721966"]
see "this":http://www.voslov.com/c++/qt/showPage.php?ID=281&SAMPLEID=QFileSystemWatcherDetectDirandFileChange[/quote]about tou code.. u are claiming to monitor the /usr folder.. try to monitor a folder in your Desktop and then delete this folder..
The only different your code have, is the fileChanged signal, which in my code will do anything when u delete the monitored folder itself...
[quote author="Andre" date="1359729069"]Looks to me like you should connect to the fileChanged signal too. The documentation for directoryChanged only talks about changes to the content of the directory, like a file in that directory being added, renamed or removed. However, the documentation for fileChanged talk about changes to the changes to the monitored path itself. I bet directoryChanged also doesn't fire when you change the name of the directory you're monitoring.
I do admit that the docs can use a bit more clarity here, but this is what I read from it.[/quote]
Andre the only way i can think of doing something like this is to have a 2nd filesystemwatcher which will monitor the folder that the monitored folder is( confusing? hope not ).. Can u think of something else?
-
[quote author="Andre" date="1359801908"]Did you try listening for the fileChanged signal as well as the directoryChanged signal?[/quote]
By listening you mean the thing i do in the video? (Have u seen it?)
the file changed signal will never emit.. whatever i do.. rename a picture, delete picture, delete folder.. it never sends signal..