Important: Please read the Qt Code of Conduct -

QCoreApplication::processEvents() and QEventLoop::ExcludeUserInputEvents

  • I've been reading this page a few times trying to understand exactly what is going on:


    In particular, they talk about how a function could be "recursed" if you use processEvents() and then call that same function again from a UI event event while it is still running from a prior similar UI event, and how passing QEventLoop::ExcludeUserInputEvents can prevent this by instead queuing the subsequent UI click.

    Do I interpret this to mean that if you pass QEventLoop::ExcludeUserInputEvents then subsequent UI events are still going to affect program operation, but that they will wait until current processes are complete and proceed down the UI event queue one-by-one, each UI event waiting for the prior one to complete whatever function it launched?

    If you do not pass QEventLoop::ExcludeUserInputEvents, what exactly is happening? The same function could be running multiple times simultaneously? I don't know what that really means.

  • When you create responsive ui (eg. thread is doing it's job in button click ,or you use processMessages), if user clicks again onto button (while processing first click) it will start unwanted new processing.
    So if you add QEventLoop::ExcludeUserInputEvents input events won't be processed until first processMessages() without that flag. That means that you can successfully finish your job in button click slot and then disconnect it or set some flag so it won't process new click for same data.
    Postponed input events will come on later, but they will not trigger your code again since you disconnected that slot or made any barrier.

Log in to reply