Wait until QWidget closes
The QWidget will be close:
In MyClass inherit QDialog. modal will be open with dialog exec()
void MainWindow::createMyDialog() { MyClass dialog(this); dialog.exec(); }
Just click this link http://qt-project.org/doc/qt-4.8/qdialog.html
The alternative code is:
#include <QEventLoop> void doStuff() { // Creating an instance of myClass MyClass myInstance; // (optional) myInstance.setAttribute(Qt::WA_DeleteOnClose); myInstance.show(); // This loop will wait for the window is destroyed QEventLoop loop; connect(this, SIGNAL(destroyed()), & loop, SLOT(quit())); loop.exec(); }