title: Qt parent mechanism
body: <p>There is one <code>QPushButton</code> in a <code>QWidget</code>, <code>click</code> the button should open another <code>QWidget</code>, as coded below:</p>
  
  <p>project.pro</p>
  
  <pre><code>QT       += core gui
  
  greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
  
  TARGET = untitled
  TEMPLATE = app
  
  CONFIG(debug, debug|release) {
      DESTDIR = debug
  } else {
      DESTDIR = release
  }
  
  INCLUDEPATH += ..
  
  SOURCES += ../main.cpp\
             ../widget.cpp \
             ../secondwidget.cpp
  
  HEADERS  += ../widget.h \
              ../secondwidget.h
  </code></pre>
  
  <p>widget.h</p>
  
  <pre><code>#ifndef WIDGET_H
  #define WIDGET_H
  
  #include &lt;QWidget&gt;
  
  class Widget : public QWidget
  {
      Q_OBJECT
  
  public:
      Widget(QWidget *parent = 0);
      ~Widget();
  };
  
  #endif // WIDGET_H
  </code></pre>
  
  <p>widget.cpp</p>
  
  <pre><code>#include "widget.h"
  
  #include &lt;QVBoxLayout&gt;
  #include &lt;QPushButton&gt;
  
  #include "secondwidget.h"
  
  Widget::Widget(QWidget *parent)
      : QWidget(parent)
  {
      resize(400, 300);
      QVBoxLayout *vLayout = new QVBoxLayout(this);
      QPushButton *bt = new QPushButton("Open 2nd Widget");
      vLayout-&gt;addWidget(bt, 1, Qt::AlignRight);
  
      SecondWidget *secondWidget = new SecondWidget();
  //    SecondWidget *secondWidget = new SecondWidget(this);
      connect(bt, &amp;QPushButton::clicked, secondWidget, &amp;SecondWidget::show);
  }
  
  Widget::~Widget()
  {
  
  }
  </code></pre>
  
  <p>secondwidget.h</p>
  
  <pre><code>#ifndef SECONDWIDGET_H
  #define SECONDWIDGET_H
  
  #include &lt;QWidget&gt;
  
  class SecondWidget : public QWidget
  {
      Q_OBJECT
  public:
      explicit SecondWidget(QWidget *parent = 0);
  
  signals:
  
  public slots:
  };
  
  #endif // SECONDWIDGET_H
  </code></pre>
  
  <p>secondwidget.cpp</p>
  
  <pre><code>#include "secondwidget.h"
  
  SecondWidget::SecondWidget(QWidget *parent) : QWidget(parent)
  {
      setAttribute( Qt::WA_QuitOnClose, false );
  }
  </code></pre>
  
  <p>Passing <code>this</code> for the <code>SecondWidget</code> constructor (as in the commented line) will brake my logic at some point. So the <code>SecondWidget</code> doesn't show anymore, when the button is clicked.</p>
  
  <p>What's going on?</p>