Quote Originally Posted by amleto View Post
if you dialog is meant to be scope limited, then there is no point in using new and creating the dialog on the heap. The only reason to use the heap is for longer lifetime of instances (or occasionally forced by memory limit of stack).

Therefore you should not be using 'new' on a dialog if you are also going to use WA_DeleteOnClose (since it will necessarily be closed before it exits scope).
Hi amleto!

The "new" way is often used in many examples of qt and unless you use a modified destructor with some output for example, you will not notice that it will not be called.
You can try that in my example mentioned before. Just insert a qDebug() output in the "CPlotterMainWindow()" (or your own class that you call with "new") and you will see
that it will not be reached if that "WA_DeleteOnClose" is not there (but i think you already know that).
It was just an example there. But it still shows what it's about to show.
I didn't want to start a programming-style-discussion here
I just tried to show the way(s) how you can "reach" the destructor. And I think that this example does that.

I probably should have written that for your case:
Qt Code:
  1. void MainWindow::openRecord(int anID, int aType)
  2. {
  3. if (aType < 4)
  4. {
  5. TransactionDialog *transactionDialog = new TransactionDialog(this, anID, aType);
  6. transactionDialog->show();
  7. transactionDialog->setAttribute(Qt::WA_QuitOnClose);
  8. transactionDialog->setAttribute(Qt::WA_DeleteOnClose);
  9. }
  10. }
To copy to clipboard, switch view to plain text mode 

Cheers