Originally Posted by
Raccoon29
the dialog, when pushed its button, comes up for a fifth of second and then disappears.
Just to ensure, you are allocating the dialog on the heap (like the code snippet in the first post suggests), right? Allocating the dialog accidentally on the stack usually leads to similar problems than you have described.
heap vs. stack
{
dialog->show();
} // dialog remains alive
{
QDialog* dialog = new QDialog(this);
dialog->show();
} // dialog remains alive
To copy to clipboard, switch view to plain text mode
{
dialog.show();
} // dialog goes out of scope
{
QDialog dialog(this);
dialog.show();
} // dialog goes out of scope
To copy to clipboard, switch view to plain text mode
On the other hand, QDialog::exec() makes it work because it blocks:
{
dialog.exec(); // starts an event loop and blocks as long as the dialog is visible
}
{
QDialog dialog(this);
dialog.exec(); // starts an event loop and blocks as long as the dialog is visible
}
To copy to clipboard, switch view to plain text mode
Bookmarks