I have this code:
Qt Code:
  1. void MainWindow::on_actionSomeButton_triggered()
  2. {
  3. QWidgetDerivedClass *wid = new QWidgetDerivedClass ;
  4. wid->show();
  5. }
To copy to clipboard, switch view to plain text mode 

If I create the widget with Qt::WA_DeleteOnClose, this will free the memory allocated with new operator, when the user closes the widget? If not, to free the memory, is it valid to do:

Qt Code:
  1. QWidgetDerivedClass::~QWidgetDerivedClass()
  2. {
  3. delete this;
  4. }
To copy to clipboard, switch view to plain text mode 
Just want to make share I'm not leaking memory.