title: Creating tabs in Qt using QTabWidget
body: <p><a href="http://qt-project.org/doc/qt-4.8/qtabwidget.html#details" rel="nofollow">Here</a> they tell us how to create tabs:</p>
  
  <ul>
  <li>Create a <code>QTabWidget</code>. </li>
  <li>Create a <code>QWidget</code> for each of the pages in the
  tab dialog, but do not specify parent widgets for them. </li>
  <li>Insert child
  widgets into the page widget, using layouts to position them as
  normal. </li>
  <li>Call <code>addTab()</code> or <code>insertTab()</code> to put the page widgets into the
  tab widget, giving each tab a suitable label with an optional
  keyboard shortcut.</li>
  </ul>
  
  <p>So, I created a tab widget:</p>
  
  <pre><code>class mainWindow : public QDialog
  {
      Q_OBJECT
      QWidget* m_mainWindow;
  
      QTabWidget* tab;
      ...
  </code></pre>
  
  <p>Then I have a Widget Class that defines a "page":</p>
  
  <pre><code>class tradeView : public QWidget
  {
      Q_OBJECT
  
      QWidget* tradeWidget;
      ...
  </code></pre>
  
  <p>THis is how the c'tor of the widget (that is supposed to go into the tab as a page) looks like:</p>
  
  <pre><code>tradeView::tradeView()
  {
      tradeWidget = new QWidget;
      tradeWidget-&gt;setWindowTitle("Trade View");
  
      tradeWidget-&gt;setGeometry(150,18,1800,800);
  
      m_pTableWidget = new QTableWidget(this);
      m_pTableWidget-&gt;setRowCount(100);
      m_pTableWidget-&gt;setColumnCount(6);
      m_TableHeader&lt;&lt;"Client Id"&lt;&lt;"Symbol"&lt;&lt;"Quantity"&lt;&lt;"Strategy Id"&lt;&lt;"Expiry" &lt;&lt; "Side";
      m_pTableWidget-&gt;setHorizontalHeaderLabels(m_TableHeader);
      m_pTableWidget-&gt;verticalHeader()-&gt;setVisible(false);
      m_pTableWidget-&gt;setEditTriggers(QAbstractItemView::NoEditTriggers);
      m_pTableWidget-&gt;setSelectionBehavior(QAbstractItemView::SelectRows);
      m_pTableWidget-&gt;setSelectionMode(QAbstractItemView::SingleSelection);
      m_pTableWidget-&gt;setShowGrid(false);
      m_pTableWidget-&gt;setStyleSheet("QTableView {selection-background-color: red;}");
      m_pTableWidget-&gt;setGeometry(QApplication::desktop()-&gt;screenGeometry());
  
      QHBoxLayout *layout = new QHBoxLayout;
      layout-&gt;addWidget(m_pTableWidget);
      tradeWidget-&gt;setLayout(layout);
  }
  </code></pre>
  
  <p>Then I did the following inside my main dialog c'tor:</p>
  
  <pre><code>mainWindow::mainWindow(QWidget* parent):QDialog(parent)
  {
      m_mainWindow = new QWidget;
      m_mainWindow-&gt;setWindowTitle("Main Window");
      QVBoxLayout *layout = new QVBoxLayout;
      tradeView* tradeViewWindow = new tradeView();
      orderView* orderViewWindow = new orderView();
      tab = new QTabWidget(this);
      tab-&gt;addTab(tradeViewWindow, "Trade");
      tab-&gt;addTab(orderViewWindow, "Order");
  
      layout-&gt;addWidget(tab);
      m_mainWindow-&gt;setLayout(layout);
      m_mainWindow-&gt;setGeometry(150,18,1850,900);
  
      m_mainWindow-&gt;show();
  </code></pre>
  
  <p>}</p>
  
  <p>I was expecting the widget to show up in the tab. 
  But when I run the code, the tab is created, but is completely empty. </p>
  
  <p>What am I missing here ? </p>