QSocketNotifier - How to use it to watch a file? - linux
I want my c++ appli开发者_Python百科cation to watch for changes in a file called "aaa". I want to do it by QSocketNotifier. I didn't understand from the documentation how to do it. Can you please send me a sample?
10!
Use QFileSystemWatcher. It performs all the inotify hackery for you.
The QSocketNotifier class works with sockets, not files. Since it apparently uses select(2) under the hood, you might get away with passing it a file descriptor returned by inotify_init() and trick it into monitoring file changes that way. That's highly doubtful, though.
精彩评论