Qt-interest Archive, February 2007
QFileSystemWatcher - signal directoryChanged is not called
Message 1 in thread
Hi,
I'm working on file management application and I have some problem with
QFileSystemWatcher class:
I successfully connected signal directoryChanged to my slot and add
directory to watch. Then when in my application I create directory (by
QDir class - mkpath) in the watched directory the slot is not called.
But what is interesting - when I create the directory for example in
Total Commander the slot is called. I really don't know why. The same
with creating files - my applications is notified only when something
happened outside of it.
Can you help me or explain what am I doing wrong? Thank you.
--
[ signature omitted ]
Message 2 in thread
Isshou a écrit :
> Hi,
> I'm working on file management application and I have some problem
> with QFileSystemWatcher class:
> I successfully connected signal directoryChanged to my slot and add
> directory to watch. Then when in my application I create directory (by
> QDir class - mkpath) in the watched directory the slot is not called.
> But what is interesting - when I create the directory for example in
> Total Commander the slot is called. I really don't know why. The same
> with creating files - my applications is notified only when something
> happened outside of it.
> Can you help me or explain what am I doing wrong? Thank you.
It's the way QFileSystemWatcher is mean to work : watching files/folders
modified outside of your application.
P@sNox,
--
[ signature omitted ]
Message 3 in thread
> It's the way QFileSystemWatcher is mean to work : watching files/folders
> modified outside of your application.
This is interesting. Isn't it more work for the Trolls to distinguish
between external and internal changes? I just checked the docu and could
not find any hint that it is different from where the file/dir is
changed. If this what you say is true, it is at least a documentation
bug.
Guido
--
[ signature omitted ]
Message 4 in thread
On Monday 05 February 2007 09:21, Nox PasNox wrote:
> Isshou a écrit :
> > Hi,
> > I'm working on file management application and I have some problem
> > with QFileSystemWatcher class:
> > I successfully connected signal directoryChanged to my slot and add
> > directory to watch. Then when in my application I create directory (by
> > QDir class - mkpath) in the watched directory the slot is not called.
> > But what is interesting - when I create the directory for example in
> > Total Commander the slot is called. I really don't know why. The same
> > with creating files - my applications is notified only when something
> > happened outside of it.
> > Can you help me or explain what am I doing wrong? Thank you.
You need to provide some more information. What path are you watching and
where are you creating directories? (sorry I am pretty sure most people here
don't know where "Total Commander" is)
> It's the way QFileSystemWatcher is mean to work : watching files/folders
> modified outside of your application.
>
> P@sNox,
That is incorrect, if you use QDir to create a directory, say /tmp/foo and you
were watching /tmp you should get a signal. It doesn't matter who created
it.
-Benjamin Meyer
--
[ signature omitted ]
Message 5 in thread
I'm sorry I wasn't able to respond earlier (btw is possible to post
messages here just by email? I can't find out how, email returns to me
with explanation I'm not subscribed).
So, paths... ok, for example - I have C:/X and I add this by
QFileSystemWatcher::addPath("C:/X"). Then when I call command
QDir::mkpath("C:/X/Y") signal QFileSystemWatcher::directoryChanged is
not called. When I create the same directory in other application signal
is called. By creating directory in Total Commander I meant create it in
that application, no in application's directory :) .
And I tested it little more and I realized that it sometimes works and
sometimes it doesn't. Maybe sometimes it doesn't catch the change, I
don't know. I will test it later on Linux if it's the same. For example
I deleted several files in my application and the list refreshes as
files were deleted but the last one remains in the list (but was deleted
as I can see after manual refresh or in another application).
If you would like to look on it it's here:
http://filecommander.svn.sourceforge.net/viewvc/filecommander/trunk/
the QFileSystemWatcher is in Panel class.
I will try to test it much more or add my own notification after changes
to files I made to make it work properly. I think if it catches changes
to files outside application the implementation of QFileSystemWatcher is
correct. The only thing is to find out why it doesn't catch all changes
I made.
--
[ signature omitted ]
Message 6 in thread
Hi,
> I'm sorry I wasn't able to respond earlier (btw is possible to post
> messages here just by email? I can't find out how, email returns to me
> with explanation I'm not subscribed).
Exactly, you have subscribe to the list first before being able to send
messages to the list. Alternatively you may use the news server.
--
[ signature omitted ]