Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
QEventLoop and platform idle processing
chopper last edited by
I've got some utilities written using Qt and the utilities are built as part of a framework that non Qt applications can use.
Using iOS as an example, I've got a swift single view app test client that uses these utilities nicely - including networking calls (because the networking calls happen in a child thread where I've got a Qt Event Loop operating) - everything works great so far.
Now, I'd like to make some of the calls into my utilities asynchronous (they are currently synchronous only) and want to allow clients to supply callbacks to my utilities.
Nothing special about this at this point; however, I would like to execute those callbacks in the context of the original calling thread.
If that was the main thread of a Qt application, this would be trivial - I'd use a signal and the Qt application event loop would receive it. It's not though.
I can guarantee that it's the main UI thread of the application - so I am wondering does Qt offer an approach that can integrate a QEventLoop with the native event loop of the main thread (e.g. performing the QEventLoop processing when the native loop is idle) so that my utility code can setup a slot on the main thread that can be signaled from my utilities' child threads?
Barring that, is it possible to use a QEventLoop without calling Exec to enter the loop and manually pump it myself when necessary? (E.g., I spawn a native timer on the platform in question and pump Qt messages in the QEventLoop)?
JonB last edited by JonB
does Qt offer an approach that can integrate a QEventLoop with the native event loop of the main thread (e.g. performing the QEventLoop processing when the native loop is idle)
A similar(-ish?) question was asked recently. At least have a read through https://forum.qt.io/topic/104641/how-to-combine-two-eventloops-into-one.