Getting the signal during operation the cycle.



  • Suppose we have a thread in which there is a cycle that can be run for a long time.

    Is it possible that thread could periodically check the received signals during the run of the cycle?


  • Moderators

    Yes. You just need to let the event loop process the signals and events in it's queue. This can be done in multiple ways, for example using "QEventLoop::processEvents()":http://qt-project.org/doc/qt-5/qeventloop.html#processEvents

    Be careful when using that function - it will process events and signals, which means that a slot/ event handler can be invoked when you call processEvents(). That slot may modify your object, and it will change the way your cycle is working. You need to check your code.

    Other possibility is to - for example - divide your cycle into separate methods, that are invoked using Qt::QueuedConnection. This way, the event loop will be automatically invoked when one function ends, process some events, then call your queued "cycle" slot.



  • Thank you. I used second option


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.