This is not "creating a temporary instance". This is a declaration of a (uninitialized) local variable named "dia" of type "QDialog *". And of course, it crashes too, because it is uninitialized and points to garbage.
This is what I meant:
void MyClass::on_some_slot()
{
if ( dlg.
exec() == QDialog::Accepted ) {
// do something with the result
}
// dlg goes out of scope when method exits, and is automatically destroyed
}
void MyClass::on_some_slot()
{
QDialog dlg;
if ( dlg.exec() == QDialog::Accepted )
{
// do something with the result
}
// dlg goes out of scope when method exits, and is automatically destroyed
}
To copy to clipboard, switch view to plain text mode
Bookmarks