replace QThread::msleep with QApp::processEvents