title: How to Widget inside another widget in QT?
body: <p>hi how to add widget inside widget</p>
  
  <p>i created main widget, and for the main widget headerbar come from another widget.
  here the code below</p>
  
  <p>main.cpp</p>
  
  <pre><code>#include &lt;QApplication&gt;
  #include "mainwindow.h"
  
  int main(int argl,char *argv[])
  {
      QApplication test(argl,argv);
  
      mainWindow *window=new mainWindow();
      window-&gt;setWindowState(Qt::WindowFullScreen);
      window-&gt;show();
  
      return test.exec();
  }
  </code></pre>
  
  <p>mainwindow.cpp</p>
  
  <pre><code>#include "mainwindow.h"
  #include &lt;QtGui&gt;
  #include "headerbar.h"
  #include &lt;QGridLayout&gt;
  
  mainWindow::mainWindow(QWidget *parent) : QWidget(parent)
  {
  
      QGridLayout *layout;
      headerBar *Header=new headerBar(this);
      layout-&gt;addWidget(Header,0,0);
      this-&gt;setLayout(layout);
  }
  
  
  mainWindow::~mainWindow()
  {
  
  }
  </code></pre>
  
  <p>headerbar.cpp</p>
  
  <pre><code>#include "headerbar.h"
  
  headerBar::headerBar(QWidget *parent) : QWidget(parent)
  {
      this-&gt;setMaximumHeight(24);
  }
  
  headerBar::~headerBar()
  {
  
  }
  </code></pre>
  
  <p>mainwindow.h</p>
  
  <pre><code>#ifndef MAINWINDOW_H
  #define MAINWINDOW_H
  
  #include &lt;QWidget&gt;
  
  class mainWindow : public QWidget
  {
      Q_OBJECT
  public:
      mainWindow(QWidget *parent = 0);
      ~mainWindow();
  
  signals:
  
  public slots:
  
  };
  
  #endif // MAINWINDOW_H
  </code></pre>
  
  <p>headerbar.h</p>
  
  <pre><code>#ifndef HEADERBAR_H
  #define HEADERBAR_H
  
  #include &lt;QWidget&gt;
  
  class headerBar : public QWidget
  {
      Q_OBJECT
  public:
      headerBar(QWidget *parent = 0);
      ~headerBar();
  
  signals:
  
  public slots:
  
  };
  
  #endif // HEADERBAR_H
  </code></pre>
  
  <p>while compile this code no errors. but when i am trying to run it's through error "exited with code -1073741819"</p>
  
  <p>please help me to fix this issue</p>