key = false;while (true){бла блаif (key){break}}
QCoreApplication::processEvents();if (flag) break;
C++ (Qt)QTime time_;...if ( time_.elapsed() >= 20 ) // trigger every 20 ms{ QCoreApplication::processEvents(); if ( flag ) break; time_.start();}