QDialog *dia;
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:

Qt Code:
  1. void MyClass::on_some_slot()
  2. {
  3. QDialog dlg;
  4. if ( dlg.exec() == QDialog::Accepted )
  5. {
  6. // do something with the result
  7. }
  8.  
  9. // dlg goes out of scope when method exits, and is automatically destroyed
  10. }
To copy to clipboard, switch view to plain text mode