title: C++, Qt : deallocation of "non attribute" objects created in constructor
body: <p>In the following example of a Qt class, many objects are created in the constructor and in functions called by the constructor, but are not pointed at by attribute pointers and, from what I understood, cannot be deleted in the destructor (there is at not point in any of the files the keyword delete).</p>
  
  <p><a href="http://qt-project.org/doc/qt-4.8/widgets-groupbox.html" rel="nofollow">http://qt-project.org/doc/qt-4.8/widgets-groupbox.html</a></p>
  
  <p>in window.h</p>
  
  <pre><code>class Window : public QWidget
  {
      Q_OBJECT
  
  public:
       Window(QWidget *parent = 0);
  
  private:
       QGroupBox *createFirstExclusiveGroup();
       QGroupBox *createSecondExclusiveGroup();
       QGroupBox *createNonExclusiveGroup();
       QGroupBox *createPushButtonGroup();
  };
  </code></pre>
  
  <p>in window.cpp</p>
  
  <pre><code>Window::Window(QWidget *parent)
       : QWidget(parent)
   {
       QGridLayout *grid = new QGridLayout;
       grid-&gt;addWidget(createFirstExclusiveGroup(), 0, 0);
       grid-&gt;addWidget(createSecondExclusiveGroup(), 1, 0);
       grid-&gt;addWidget(createNonExclusiveGroup(), 0, 1);
       grid-&gt;addWidget(createPushButtonGroup(), 1, 1);
       setLayout(grid);
  
       setWindowTitle(tr("Group Boxes"));
       resize(480, 320);
   }
  
   QGroupBox *Window::createFirstExclusiveGroup()
   {
       QGroupBox *groupBox = new QGroupBox(tr("Exclusive Radio Buttons"));
  
       QRadioButton *radio1 = new QRadioButton(tr("&amp;Radio button 1"));
       QRadioButton *radio2 = new QRadioButton(tr("R&amp;adio button 2"));
       QRadioButton *radio3 = new QRadioButton(tr("Ra&amp;dio button 3"));
  
       radio1-&gt;setChecked(true);
  
       QVBoxLayout *vbox = new QVBoxLayout;
       vbox-&gt;addWidget(radio1);
       vbox-&gt;addWidget(radio2);
       vbox-&gt;addWidget(radio3);
       vbox-&gt;addStretch(1);
       groupBox-&gt;setLayout(vbox);
  
       return groupBox;
   }
  </code></pre>
  
  <p>Am I missing something or is it a "bad" example of implementation ?
  Would a correct implementation be to put the pointers as attribute of class Window and destroy what they point at in ~Window() ? Thank you.</p>