Hi all,

I've got a Qt project which the statement below is written in its .cpp file's constructor:

Qt Code:
  1. setAttribute(Qt::WA_DeleteOnClose);
To copy to clipboard, switch view to plain text mode 

The program, by the way, inherits from QMainWindow:

in the header file:
Qt Code:
  1. class MyProgram : public QMainWindow
To copy to clipboard, switch view to plain text mode 

I think the meaning of the first statement is that, when I close the project (MyProgram), the Qt Creator compiler (MinGW) deletes all objects created by new in the project.
Is it right up to here?

If so, why is it needed whatsoever? When we close the project, on Windows/Mac etc, all objects, statements, functions and whatever exists inside the project will be freed/deleted and when we open the project once again, they will be assigned once again. So, I don't know why we still need:
Qt Code:
  1. setAttribute(Qt::WA_DeleteOnClose);
To copy to clipboard, switch view to plain text mode 

To me, it does nothing and is redundant.

Am I wrong, please?
If possible please guide me in this case.