Results 1 to 5 of 5

Thread: Watching Directory for changes ??

  1. #1
    Join Date
    Jun 2012
    Posts
    173
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows
    Thanks
    48
    Thanked 2 Times in 2 Posts

    Default Watching Directory for changes ??

    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.

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

    Default Re: Watching Directory for changes ??

    Hi, have a look at QFileSystemWatcher to monitor a directory, but if only your application adds log files you do not really need this.

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

    jesse_mark (22nd March 2013)

  4. #3
    Join Date
    Jun 2012
    Posts
    173
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows
    Thanks
    48
    Thanked 2 Times in 2 Posts

    Default Re: Watching Directory for changes ??

    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 .

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

    Default Re: Watching Directory for changes ??

    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.

  6. #5
    Join Date
    Jun 2012
    Posts
    173
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows
    Thanks
    48
    Thanked 2 Times in 2 Posts

    Default Re: Watching Directory for changes ??

    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

Similar Threads

  1. Replies: 0
    Last Post: 19th February 2013, 17:46
  2. Replies: 2
    Last Post: 20th January 2011, 08:09
  3. get .pro directory
    By Alnitak in forum Qt Programming
    Replies: 5
    Last Post: 14th October 2010, 19:43
  4. Watching a UNIX file descriptor
    By invictus in forum Newbie
    Replies: 1
    Last Post: 13th January 2009, 21:26
  5. Specify the DLL directory
    By Nyphel in forum Newbie
    Replies: 6
    Last Post: 27th April 2007, 15:29

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
  •  
Qt is a trademark of The Qt Company.