Unsolved QFileSystemWatcher is working for changes inside too.
-
Hello,
i have following problem:
I'm using the QFileSystemWatcher with fileChanged to call a function when the file is edited outside the UI. For that I'm using the connect.
The file I'm using is an XML that is called from the QTreeView.So but now i have the problem if I'm going to change the Model inside the UI the function is called again. But it was planned only for changes outside the UI.
Do you know why? And how can i solved that?
Regards
-
@developer_61 said in QFileSystemWatcher is working for changes inside too.:
if I'm going to change the Model inside the UI the function is called again
Does the model change this file? QFileSystemWatcher does not care who changes a file...
-
@jsulm yes the model change the file ... :/ no option?
-
@developer_61 said in QFileSystemWatcher is working for changes inside too.:
no option?
I already wrote: "QFileSystemWatcher does not care who changes a file..."
-
@developer_61
Like I said here:https://forum.qt.io/topic/124575/is-there-any-way-to-recognize-if-a-data-is-changed-from-outsidekeep track of when you inside your program modify the file. Then when the file system watcher notifies you, check if the times match with your last modification.
If they do ignore the signal -
@J-Hilk and what if i'm changing the file outside? it will match with my last modification again and ignore the signal ?
-
and what if i'm changing the file outside? it will match with my last modification again and ignore the signal ?
why would it match with your last modification ?
-
@J-Hilk
cause if i'm editing the file outside and save it then it will trigger the function.
If i'm going to to edit the file inside the programm and click save inside the programm it will change my file and trigger then the function. So there is no difference between outside and inside. It will trigger the function after save. -
cause if i'm editing the file outside and save it then it will trigger the function.
If i'm going to to edit the file inside the programm and click save inside the programm it will change my file and trigger then the function. So there is no difference between outside and inside. It will trigger the function after save.soo, working as intended ? Whats the point of this topic then?
-
@J-Hilk i don't want to call the function after i change it inside. But the problem is that the change inside the programm changes the file and call the function.
-
We're arguing in circles.
I'm sure you'll figure it out, good luck
-
@developer_61
So it seems you have a couple of choices. When you change the file from inside your program:-
Switch off the file notification beforehand, re-enable it afterwards.
-
Note the time at which you perform the internal update. Ignore notification for a period afterwards.
-
-
This post is deleted!