title: Qt::WA_DeleteOnClose
body: <p>I am learning Qt and trying some examples in the book "Foundations of Qt Development".
  In the book, there is a section teaching Single Document Interface with an example creating a simple app like a notepad.</p>
  
  <pre><code>MainWindow::MainWindow(QWidget *parent) :
      QMainWindow(parent),
      ui(new Ui::MainWindow)
  {
      ui-&gt;setupUi(this);
      setAttribute(Qt::WA_DeleteOnClose);
      setWindowTitle(QString("%1[*] - %2").arg("unnamed").arg("SDI"));
  
      connect(ui-&gt;docWidget-&gt;document(), SIGNAL(modificationChanged(bool)), this, SLOT(setWindowModified(bool)));
  
      createActions();
      createMenu();
      createToolbars();
  
      statusBar()-&gt;showMessage("Done");    
  }
  </code></pre>
  
  <p>The book said that "Setting the windows attribute to <code>Qt::WA_DeleteOnClose</code> so that Qt takes care of deleting the window from memory as soon as it is closed.</p>
  
  <p>How it works?</p>
  
  <p>Because if i use <code>setAttribute(Qt::WA_DeleteOnClose);</code>, when I end the program, there is a <code>Debug Assertion Failed warning:_BLOCK_TYPEIS_VALID(pHead-&gt;nBlockUse)</code>.
  There is no problem if the <code>setAttribute</code> is removed.</p>