Hello!

I have a widget subclassing QFrame and it has a layout and lots of other widgets inside it. I'm wondering how to code the destructor right.

Qt Code:
  1. MyFrame::MyFrame(QWidget *parent) : QFrame(parent)
  2. {
  3. // Build inner parts.
  4. QFrame *header = new QFrame;
  5. QFrame *footer = new QFrame;
  6.  
  7. QHBoxLayout layout;
  8. layout.addWidget(header);
  9. layout.addWidget(footer);
  10. setLayout(&layout);
  11.  
  12. SomeOwnObject someOwnObject = new SomeOwnObject();
  13. }
  14.  
  15. MyFrame::~MyFrame()
  16. {
  17. if (someOwnObject != NULL)
  18. delete someOwnObject;
  19. }
To copy to clipboard, switch view to plain text mode 

I figure I do need to delete my own object. In the documentation it says that the widget takes ownership of the layout when setLayout(layout) is called and also that the layout takes ownership of a widget when layout->addWidget(widget) is called. So basicly I'm unsure if I somehow need to call the destructor of the superclass or maybe delete the layout.