Results 1 to 4 of 4

Thread: Does Qt creates any thread for handling Events?

  1. #1
    Join Date
    Sep 2013
    Posts
    33
    Thanks
    5
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows Android

    Question Does Qt creates any thread for handling Events?

    There is some Concepts like Event Queue/Event loop for Queuing the Events and proceeding one after another.If there is an extra thread to respond OS events, no problem to make a Event Queue and dispatch one by one when main thread will finish one task(executing set of codes after an event).
    But what’s the scenario if only one thread is present?
    Please take a look at flow asked in a Question
    http://stackoverflow.com/questions/1...d-events-loops
    —and help me.

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Does Qt creates any thread for handling Events?

    Qt does not create any threads to handle events. Events have affinity with threads, not the other way round.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  3. The following user says thank you to wysota for this useful post:

    blue_sky (5th September 2013)

  4. #3
    Join Date
    Sep 2013
    Posts
    33
    Thanks
    5
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows Android

    Default Re: Does Qt creates any thread for handling Events?

    It means the Event Queue is accessible by both the thread and OS Event Dispatcher.Otherwise how an executing thread can add a message from OS,while it processing some other codes? Am I right?

    Quote Originally Posted by wysota View Post
    Qt does not create any threads to handle events. Events have affinity with threads, not the other way round.
    It means the Event Queue is accessible by both the thread and OS Event Dispatcher.Otherwise how an executing thread can add a message from OS,while it processing some other codes? Am I right?
    Last edited by blue_sky; 6th September 2013 at 06:32.

  5. #4
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Does Qt creates any thread for handling Events?

    Not sure what you mean with "OS Event Dispatcher".

    Each thread has a QEventDispatcher instance, each usually hooked into the OS to process system events such as timers and sockets.
    The event dispatcher instance is where the thread "sleeps", i.e. waits for events.

    Whether OS events can be added while the thread is processing depends on how the OS event API works.
    If it is "pull" based, e.g. like Unix select(), then no. The thread will see the new event when it returns to the event dispatcher.

    If it is callback based and the system has its own thread for doing those callbacks, then yes, that system thread might add events while another is being processed. No idea if the only non-Unix platform (Windows) does that.

    Cheers,
    _

Similar Threads

  1. OS specific events handling
    By oficjalne100 in forum Qt Programming
    Replies: 1
    Last Post: 1st November 2011, 02:14
  2. Handling mouse events in Qt WebKit
    By yakin in forum Qt Programming
    Replies: 6
    Last Post: 21st April 2011, 05:44
  3. Handling mouse events
    By Maluko_Da_Tola in forum Newbie
    Replies: 13
    Last Post: 28th August 2010, 00:37
  4. Handling parent und child events at once.
    By dentist in forum Newbie
    Replies: 3
    Last Post: 2nd April 2010, 10:55
  5. handling keyboard events from a console app
    By g.cavallin in forum Qt Programming
    Replies: 1
    Last Post: 18th December 2006, 22:31

Tags for this Thread

Bookmarks

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.