PDA

View Full Version : Watching Directory for changes ??



jesse_mark
21st March 2013, 21:09
Hello guys,

I want to watch a specific directory for any new files that appears in it.

basically, I have an application that will run and generate logs file while its running. What i want to do, is to watch the directory where those log files are generated and and create a table to add the log files names in it.

so any suggestion of how can i do this, or maybe any suggesting of how can i represent those log files to the user using GUI.

all suggestion are highly appreciated,

Thank you in advance.

Lykurg
21st March 2013, 21:22
Hi, have a look at QFileSystemWatcher to monitor a directory, but if only your application adds log files you do not really need this.

jesse_mark
22nd March 2013, 14:06
Thanks for pointing me to this class.


but if only your application adds log files you do not really need this.

yeah i just want to add new log files, so how do you suggest me to do it without the watcher ?

Thanks .

Lykurg
22nd March 2013, 18:41
Well, maybe I get you wrong, but every time you create a file, emit a custom signal with the filename. Then catch that signal at an appropriate place in your app, and do what every you like. E.g. put the filename in a QListWidget.

jesse_mark
22nd March 2013, 21:59
i see. the reason that i want a watcher is that the application that creates the log files is another application which I do not have access to.

but i found " QFileSystemModel" that i set to my tableview.
QFileSystemModel does has QFileSystemWatcher, if i create/delete a file my self from a terminal the QFileSystemModel catch the file and update my model with the new change.

BUT the issue i am facing is

If the file was created by the application the QFileSystemWatcher in the QFileSystemModel want see it.. !!! which i dont know why or what should i do to make it see it.

Thanks