How to add new event to qt default event loop?
-
Hello,
I think you need to use Signals and Slots. Which are the easiest way with Qt to propagate event between threads.
If your goal is to monitor file changes, you may consider using QFileSystemWatcher which is already designed to monitor changes in files and/or folders.
-
I have a few file descriptors, in c, I can use poll() to monitor them in a single thread. Now I would like to learn how to use Qt to monitor them, using default eventloop.
Can anyone teach me?
Thanks!!
@Mr-Pang said in How to add new event to qt default event loop?:
I have a few file descriptors, in c, I can use poll() to monitor them in a single thread. Now I would like to learn how to use Qt to monitor them, using default eventloop.
You can use QSocketNotifier (despite the name) to do that. When the descriptor's activated for reading or writing (depending on what you passed to the constructor) the
activated
signal will be raised for you. -
@Mr-Pang said in How to add new event to qt default event loop?:
I have a few file descriptors, in c, I can use poll() to monitor them in a single thread. Now I would like to learn how to use Qt to monitor them, using default eventloop.
You can use QSocketNotifier (despite the name) to do that. When the descriptor's activated for reading or writing (depending on what you passed to the constructor) the
activated
signal will be raised for you.@kshegunov
Great