title: QT5 custom widget with .ui file - calling Ui::myWidget.setupUi required when displaying it
body: <p>I created QT custom widget <code>MyWidget</code> with a <code>.ui</code> file. But when I place <code>QWidget</code> to <code>MainWindow</code>  in QT designer and promote it to <code>MyWidget</code>, <strong>it just renders an empty widget</strong>.</p>
  <p>I figured out why it doesn't work. In generated file <code>ui_mainwindow.h</code> in function <code>setupUi</code> is code for displaying my widget following:</p>
  <pre class="lang-cpp prettyprint-override"><code>widget = new MyWidget(centralWidget);
  widget-&gt;setObjectName(QString::fromUtf8(&quot;widget&quot;));
  verticalLayout-&gt;addWidget(widget);
  </code></pre>
  <p>It works, when I call <code>Ui::MyWidget.setupUi</code> (replace the code above with following):</p>
  <pre class="lang-cpp prettyprint-override"><code>widget = new MyWidget(centralWidget);
  Ui::MyWidget uiOfWidget;
  uiOfWidget.setupUi(widget);
  widget-&gt;setObjectName(QString::fromUtf8(&quot;widget&quot;));
  verticalLayout-&gt;addWidget(widget);
  </code></pre>
  <p>So my question is, how it's possible to reach one of following:</p>
  <ul>
  <li>Generate code like this automatically when compiling <code>MainWindow.ui</code> file</li>
  <li>Remove the need for calling <code>Ui::MyWidget.setupUi</code></li>
  <li>Or other fix...?</li>
  </ul>
  <p>I use QT5.  Thank you!</p>