How to add new event to qt default event loop?
-
wrote on 14 May 2018, 13:48 last edited by
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!!
-
wrote on 14 May 2018, 13:56 last edited by
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.wrote on 15 May 2018, 12:02 last edited by@kshegunov
Great
2/4