View Full Version : Event loops, Threads

28th March 2015, 09:07
I'm very confused about the term "event loop" and how such are related to threads.

First of all, in many places we talk just about "the" event loop, and mean the QApplicatiom loop, called from "main".

But, on the other hand I can create a so called "local" event loop by using QEventLoop.exec().

Question1: What is going on in that case? Does ist mean, that all events, formerly processed by the unique "main-loop" are processed now by the new, local event loop? Or are only "some" event types put into the queue of the local loop? And what is the reason for creating such a local event loop.

Moreover, I have seen, that QThreads have a slot "exec" to create a thread-related event loop.

This seems to be optionally.
Question2:When is it required to run exec() within a thread and when not?
If I decide to do that, what type of events are processed by that loop - or, in other words:
Question3: which events are going into the queue for that loop? I don't think that all subsequent mouse clicks are processed by that loop, but what are and what are not?

I hope there is somebody outside understanding my questions...

Many Thanks

28th March 2015, 09:50
Read this article (http://qt-project.org/wiki/ThreadsEventsQObjects)