Results 1 to 5 of 5

Thread: Does QCoreApplication::processEvents call posted events processing ?

  1. #1
    Join Date
    Feb 2007
    Posts
    14
    Thanks
    3

    Default Does QCoreApplication::processEvents call posted events processing ?

    My questions are:
    1. Does void QCoreApplication:: processEvents ( QEventLoop::ProcessEventsFlags flags = QEventLoop::AllEvents ) or void QCoreApplication:: processEvents ( QEventLoop:: ProcessEventsFlags flags, int maxtime ) call events processing posted by QCoreApplication:: postEvent() ?
    2. Can void QCoreApplication:: processEvents call the event processing posted from a thred (connected by Qt::QueuedConnection) ?
    Thanks.

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Does QCoreApplication::processEvents call posted events processing ?

    QCoreApplication::processEvents() processes events only from the GUI thread's queue, that is all events what where sent to it, not those which were sent from the GUI thread.

  3. #3
    Join Date
    Feb 2007
    Posts
    14
    Thanks
    3

    Default Re: Does QCoreApplication::processEvents call posted events processing ?

    So, if I post event from the non-gui thread by QCoreApplication:: postEvent or emit signal from QThread:: run, connnected as Qt:: QueuedConnection it will not process while gui thread won't return to the QApplication event loop or will be processed if I make it force by QCoreApplication:: sendPostedEvents. If I call QCoreApplication:: processEvents(...) it will NOT cause posted events processing, only paint events, timer and so on ?

  4. #4
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: Does QCoreApplication::processEvents call posted events processing ?

    Quote Originally Posted by burkav84 View Post
    So, if I post event from the non-gui thread by QCoreApplication:: postEvent or emit signal from QThread:: run, connnected as Qt:: QueuedConnection it will not process while gui thread won't return to the QApplication event loop or will be processed if I make it force by QCoreApplication:: sendPostedEvents. If I call QCoreApplication:: processEvents(...) it will NOT cause posted events processing, only paint events, timer and so on ?
    It doesn't matter where the event is posted (or a queued signal is emitted) from. What does matter is where the receiver object lives.

    If the receiver lives in the main thread (*), the event gets added to the event queue of the main thread. QCoreApplication::processEvents() is there for processing pending events from the main thread's event queue and is not safe to be called from another thread than the main thread.

    (*) with "main thread" I mean the same thread where the application object lives
    J-P Nurmi

  5. The following user says thank you to jpn for this useful post:

    burkav84 (21st February 2007)

  6. #5
    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 QCoreApplication::processEvents call posted events processing ?

    Maybe a short answer is needed - QCoreApplication::processEvents() called without parameters processes all types of events that are in the queue. Paint events, timer events, etc. are also posted, so there is no such thing as differenciating between "posted" and "other" events unless by "other" you mean spontaneous, but I'm sure they also get into the queue by using postEvent.

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

    burkav84 (21st February 2007)

Similar Threads

  1. Grab keyboard events in Windows
    By durbrak in forum Qt Programming
    Replies: 1
    Last Post: 4th February 2007, 19:56
  2. Qtoolbutton-ignoring mouse events
    By rvenugopal in forum Qt Programming
    Replies: 2
    Last Post: 26th December 2006, 22:12
  3. why cant i call setGeometry
    By freegnu in forum Qt Programming
    Replies: 1
    Last Post: 14th June 2006, 04:59
  4. QStackerWidget and mouse events
    By high_flyer in forum Qt Programming
    Replies: 3
    Last Post: 25th April 2006, 19:25
  5. Delays in processing events
    By Caius Aérobus in forum Qt Programming
    Replies: 6
    Last Post: 7th April 2006, 12:42

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.