title: why qt application always new widgets instead of on stack?
body: <p>there. I've seen this example from qt: <a href="https://doc.qt.io/qt-5/qtwidgets-widgets-calculator-example.html" rel="nofollow noreferrer">https://doc.qt.io/qt-5/qtwidgets-widgets-calculator-example.html</a>, and wonder why qt always create widgets with new instead of allocating on stack</p>
  <pre><code>Button *Calculator::createButton(const QString &amp;text, const char *member)
  {
      Button *button = new Button(text);
      connect(button, SIGNAL(clicked()), this, member);
      return button;
  }
  </code></pre>
  <p>create widget on stack is faster, and in this question: <a href="https://stackoverflow.com/questions/39931734/qt-specific-difference-of-stack-vs-heap-attributes">QT-specific difference of stack vs. heap attributes?</a>
  Mike's answer says that create on stack is perfectly fine, but why official documents use new mostly?</p>