title: How can I add items to a layout in Qt?
body: <p>I am developing an application in Qt 4.8.4, in which I do the following:</p>
  
  <p>I subclass QGridLayout as follows:</p>
  
  <pre><code>class Viewer : public QGridLayout
  {
      Q_OBJECT
      ...................
  private:
      // Objects
      /// Maximize button object
      ViewerGeneric* viewerGeneric;
  
      /// Maximize button object
      QPushButton* btnMaximize;
  
      /// Close button object
      QPushButton* btnClose;
  
      /// Connect button object
      QPushButton* btnConnect;
  
      /// Central viewer layout object
      QGridLayout* viewer;
  
      /// Indicates the row position in the main grid
      unsigned int row;
  
      /// Indicates the column position in the main grid
      unsigned int col;
  };
  </code></pre>
  
  <p>Then in the constructor I do something like this:</p>
  
  <pre><code>// Create the objects
  btnMaximize = new QPushButton("max");
  btnClose = new QPushButton("close");
  btnConnect = new QPushButton("connect");
  
  // Add the horizontal toolbar
  QHBoxLayout* toolbar = new QHBoxLayout();
  toolbar-&gt;setSizeConstraint(QLayout::SetMinimumSize);
  toolbar-&gt;addItem(new QSpacerItem(0, 0, 
                       QSizePolicy::Expanding, QSizePolicy::Minimum));
  toolbar-&gt;addWidget(btnMaximize);
  toolbar-&gt;addWidget(btnClose);
  
  // Add the 'Connect' button
  viewer = new QGridLayout();
  viewer-&gt;addWidget(btnConnect);
  
  // Add the widgets
  this-&gt;addItem(toolbar, 0, 0);
  this-&gt;addItem(viewer, 0, 0, 2);
  </code></pre>
  
  <p>But, in the end, when I show the Viewer class in my main window the window is <strong>completely blank</strong>! Hope anybody can help me. Thank you.</p>
  
  <p>Cheers,</p>