mainwindow->hide(); QEventLoop loop; while(mainToolWidget()->isVisible()) {} QTimer::singleShot(0,&loop,SLOT(quit())); loop.exec(); needwindow->show();