Trigger OSX runloop from Qt
-
27-10-2019 - |
Question
I'm writing an application in C++ using Qt on Mac. I want to detect drives being mounted and unmounted so I am using the DiskArbitration framework. I registered some callback functions via DARegisterDiskAppearedCallback
and DARegisterDiskDisappearedCallback
but these only fire when there is a runloop.
What is the best way to start a suitable runloop ?
QThread with CFRunLoopRun
(sounds a bit excessive) ?
Please give details, I am not well versed in threads.
Solution
On OS X 10.7+ you can use DASessionSetDispatchQueue
to have your callbacks invoked on a dispatch queue of your choosing. You could then forward the data from the callback over to your regular Qt event loop.
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow