[ACCEPTED]-Wait until QWidget closes-qt
Accepted answer
Have MyClass
inherit QDialog
. Then open it as a modal 1 dialog with exec()
.
void MainWindow::createMyDialog()
{
MyClass dialog(this);
dialog.exec();
}
An other way is to use a loop which waits 1 on the closing event :
#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();
}
Why not put the code you don't want to be 3 executed till the window has closed in a 2 separate function and connect this as a 1 SLOT
for the window's close SIGNAL
?
Source:
stackoverflow.com
More Related questions
Cookie Warning
We use cookies to improve the performance of the site. By staying on our site, you agree to the terms of use of cookies.