Trolltech Home | Qt-interest Home | Recent Threads | All Threads | Author | Date
All threads index page 5

Qt-interest Archive, April 2007
monitoring directory changes


Message 1 in thread

Hello list,


Is there any way I can be notified when the files in a directory change,
short of creating a QSocketnotifier object for each file? (I have a lot
of files). Can you somehow attach a notifier to a directory?


I'm guessing I'm out of luck here - but I thought I'd ask nonetheless.



Thanks,

-- 
 [ signature omitted ] 

Message 2 in thread

On 16.04.07 17:00:51, Thomas Richards wrote:
> Hello list,
> 
> 
> Is there any way I can be notified when the files in a directory change,
> short of creating a QSocketnotifier object for each file? (I have a lot
> of files). Can you somehow attach a notifier to a directory?
> 
> 
> I'm guessing I'm out of luck here - but I thought I'd ask nonetheless.

Check QFileSystemWatcher if you're using Qt4.

Andreas

-- 
 [ signature omitted ] 

Message 3 in thread

> 
> Check QFileSystemWatcher if you're using Qt4.
> 

Brilliant!

Thanks!
-- 
 [ signature omitted ] 

Message 4 in thread

> >
> > Check QFileSystemWatcher if you're using Qt4.
> >
> 
> Brilliant!
> 

Hmm, upon closer inspection, it seems to be "almost brilliant".
QFileSystemWatcher will detect changes to file just fine, but I can't
get it to detect additions to a directory.

I guess the directoryChanged() signal isn't emitted when a file is added
to the directory?

Is there any way to detect (short of continuous polling) when a file is
added to a directory?

BEGIN:VCARD
BEGIN:VCARD
VERSION:2.1
N:Richards;Thomas
FN:Thomas Richards
EMAIL;PREF;INTERNET:thomas.richards@xxxxxxxxx
REV:20070226T164514Z
END:VCARD

Message 5 in thread

Thomas Richards schrieb:
>>> Check QFileSystemWatcher if you're using Qt4.
>>>
>> Brilliant!
>>
> 
> Hmm, upon closer inspection, it seems to be "almost brilliant".
> QFileSystemWatcher will detect changes to file just fine, but I can't
> get it to detect additions to a directory.
> 
> I guess the directoryChanged() signal isn't emitted when a file is added
> to the directory?

That's the idea of this signal! I can confirm that it *is* sent when you
add files to a directory (Qt 4.2.2) being watched.

For debugging try QFileSystemWatcher::directories () and see if your
directory is indeed being watched.

Cheers, Oliver

--
 [ signature omitted ] 

Message 6 in thread

Thomas Richards schrieb:
> 
>> That's the idea of this signal! I can confirm that it *is* sent when
> you
>> add files to a directory (Qt 4.2.2) being watched.
> 
> I thought so, then I thought maybe the signal was only emitted when some
> meta data about the directory changed (permissions, ownership etc). Out
> of interest, is the signal emitted when you change meta data on a
> watched directory?

I have never tried it, but from what I understand from the Qt docs I
would assume so. But for sure it is emitted when you add files (removing
files should also cause the signal to be emitted, but have not verified
that).


Cheers, Oliver

--
 [ signature omitted ]