PDA

View Full Version : QFileSystemWatcher emits/handles fileChanged signal after complete script execution.



ajaybindal
8th May 2017, 10:40
Hi,

I am using QFileSystemWatcher to track any modifications on a file. When I am editing that file using UI, fileChanged signal is emitted after each modification but if I do that through a script, only a single fileChanged signal is emitted after the script has been executed completely and has returned control. e.g.

a. Execute an operation which impacts "file".
b. FileChanged signal is emitted.
c. Execute other operation which impact "file".
d. fileChanged signal is emitted.

So far, prefect. Now I wrote a script say editFile as

a. Execute an operation which impacts "file".
b. Execute another operation which impact "file".

Now, if I load/execute script editFile, fileChanged signal is emitted only after the script has executed completely i.e. no fileChanged signal is emitted/handled after step a. execution. Seems like some event loop that is emitting/handling fileChanged signal does that only after control has been returned from script.

Anything I can do to make sure that fileChanged signal is emitted/handled as soon as the file is edited rather than after the complete script has executed.
Thanks.

Best R
Ajay

Santosh Reddy
8th May 2017, 11:30
QApplication::processEvents(); //Try calling in-between

ajaybindal
9th May 2017, 07:52
Thanks a lot Santosh, it worked perfectly.. :)