Results 1 to 2 of 2

Thread: Event loops, Threads

  1. #1
    Join Date
    Mar 2015
    Qt products

    Default Event loops, Threads

    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
    Last edited by schnudl; 28th March 2015 at 10:16.

  2. #2
    Join Date
    Mar 2008
    Kraków, Poland
    Thanked 284 Times in 279 Posts
    Qt products
    Unix/X11 Windows

    Default Re: Event loops, Threads

Similar Threads

  1. Threads or Event loop in multiplayer hangman game
    By TheIndependentAquarius in forum Newbie
    Replies: 6
    Last Post: 1st March 2014, 09:33
  2. [solved] Understanding QML / C++ Event Loops
    By kachofool in forum Qt Quick
    Replies: 2
    Last Post: 10th May 2011, 20:24
  3. Replies: 10
    Last Post: 15th January 2010, 15:35
  4. Combining Event Loops
    By Gimpyfuzznut in forum Qt Programming
    Replies: 5
    Last Post: 10th July 2009, 07:08
  5. signal and slot across threads having event loop
    By travis in forum Qt Programming
    Replies: 6
    Last Post: 6th November 2007, 00:56

Tags for this Thread


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.