title: Accessing Qt Layout created in UI from code?
body: <p>This is probably the dumbest problem I have ever had, but I am extremely confused. I am trying to get started with layouts, but for some reason cannot figure this one out.</p>
  
  <p>I have tried adding a QGridLayout via the .ui file by just drag dropping it into my project. As I want to populate the grid with widgets upon loading, I have tried to use the "gridLayout" object in the "mainwindow.h" file both before/after the this->setupui() is called.</p>
  
  <p>As I couldn't figure that out, I opted to just try creating it from scratch using code, and added the following to the main.cpp file instead. This did not display either, so I am wondering how on earth I can populate the grid when the form loads.</p>
  
  <pre><code>#include &lt;QtGui/QApplication&gt;
  #include &lt;QtGui&gt;
  #include "mainwindow.h"
  
  int main(int argc, char *argv[])
  {
      QApplication app(argc, argv);
      MainWindow w;
  
      QGridLayout *grid = new QGridLayout;
  
      QLabel *label1 = new QLabel("test");
      QLabel *label2 = new QLabel("test 2");
  
      grid-&gt;addWidget(label1, 0, 0);
      grid-&gt;addWidget(label2, 0, 1);
      w.setLayout(grid);
  
      w.show();
      return app.exec();
  }
  </code></pre>