When you run a loop on the main thread, the main thread is busy with that loop.
It if is busy with that loop, it can't do any event processing.

There are a number of options on how to change that:

1) Restructure the code to use a timer based iteration instead of a tight loop
2) Run the loop in a secondary thread
3) Call QCoreApplication:rocessEvents() in each loop iteration to do event processing before continuing with the loop.

Cheers,
_