Greetings,

I am required to add QGroupBox objects (each containing a QTableWidget) to the QTabWIdget which resides on the central widget of my applications main window.

I have been unable to add the QGroupBox objects to the QTabWidget object. I assume it is because I don't know what to pass into the ui.setupUI( ??? ) function. The group box with the table in it appears in a separate window unattached to the programs main window when using the following code.

Qt Code:
  1. MainWin::MainWin( QWidget* parent, Qt::WFlags flags ) : QMainWindow( parent, flags )
  2. {
  3. ui.setupUi( this );
  4.  
  5. m_pCentralWidget = new QWidget;
  6. setCentralWidget( m_pCentralWidget );
  7.  
  8. // create tabs
  9. m_tabWidget = new QTabWidget( this );
  10.  
  11. ui.tabWidget = m_tabWidget;
  12.  
  13. m_tabDMX = new DMXTable( this );
  14. ui.tabWidget->addTab( m_tabDMX, tr("First Tab") );
  15.  
  16. m_tabAll = new AllTab( this );
  17. ui.tabWidget->addTab( m_tabAll, tr("Second Tab") );
  18.  
  19. // Load frame with required stuff; Place widgets in frame; left to right
  20. QFrame* qFrame = new QFrame( this );
  21. qFrame->setFrameRect( QRect( 0, 0, 0, 0 ) );
  22. qFrame->setFrameStyle( QFrame::Box | QFrame::Plain );
  23.  
  24. // Checkbox in frame
  25. m_onlineChk = new QCheckBox( "Show Online Table ", qFrame );
  26. m_onlineChk->setToolTip( "Show/Hide Online Table" );
  27. connect( m_onlineChk, SIGNAL( clicked() ), this, SLOT( onlineClicked() ) );
  28. m_onlineChk->setCheckState( Qt::Checked );
  29.  
  30. QHBoxLayout* frameLayout = new QHBoxLayout( qFrame );
  31. frameLayout->setSizeConstraint( QLayout::SetMaximumSize );
  32. frameLayout->addWidget( m_onlineChk, 0, Qt::AlignRight );
  33. frameLayout->insertStretch( 0, 0 );
  34. qFrame->setLayout( frameLayout );
  35.  
  36. // Put everything onto the main window.
  37. m_centralLayout = new QGridLayout;
  38.  
  39. // Tab widget is 1st
  40. m_centralLayout->addWidget( m_tabWidget, 1, 0, 1, 1);
  41.  
  42. // Frame is on bottom (just above the status bar)
  43. m_centralLayout->addWidget( qFrame, 2, 0, 1, 1 );
  44.  
  45. m_pCentralWidget->setLayout( m_centralLayout );
  46.  
  47. m_pExitAct = new QAction( tr("E&xit"), this );
  48. m_pExitAct->setShortcut( tr("Ctrl+Q") );
  49. connect( m_pExitAct, SIGNAL(triggered()), this, SLOT(close()) );
  50.  
  51. m_pFileMenu = menuBar()->addMenu( tr("&File") );
  52. m_pFileMenu->addAction( m_pExitAct );
  53.  
  54. show();
  55. }
To copy to clipboard, switch view to plain text mode 

Qt Code:
  1. // DMX Table Tab Class
  2. DMXTable::DMXTable( QWidget* pParent ) : QWidget( /*pParent*/ )
  3. {
  4. m_parent = reinterpret_cast<MainWin*>( pParent );
  5.  
  6. ui.setupUi( m_parent );
  7. // ui.setupUi( this );
  8.  
  9. m_onlineGroupBox = new QGroupBox( tr("Online Devices") );
  10.  
  11. QScrollArea* pTableArea = new QScrollArea;
  12. m_pOnlineTable = new QTableWidget( 1, 5, m_parent );
  13.  
  14. QStringList sLabels;
  15. sLabels << "Status" << "Name" << "Type" << "IP Address" << "Model Name";
  16.  
  17. m_pOnlineTable->setHorizontalHeaderLabels( sLabels );
  18. m_pOnlineTable->setColumnWidth( 0, 40 );
  19. m_pOnlineTable->setColumnWidth( 1, 150 );
  20. m_pOnlineTable->setColumnWidth( 2, 130 );
  21. m_pOnlineTable->setColumnWidth( 3, 120 );
  22. m_pOnlineTable->setColumnWidth( 4, 200 );
  23.  
  24. pTableArea->setWidgetResizable( true );
  25. pTableArea->setWidget( m_pOnlineTable );
  26.  
  27. QGridLayout* layout = new QGridLayout;
  28. layout->addWidget( pTableArea, 0, 0 );
  29.  
  30. m_onlineGroupBox->setLayout( layout );
  31. m_onlineGroupBox->show();
  32. }
To copy to clipboard, switch view to plain text mode 
If I use "ui.setupUi( this )" in the DMXTable class I get the following compiler error: 'Ui_DMXTableClass::setupUi': cannot convert parameter 1 from 'DMXTable *const' to 'QMainWindow *'.

I don't understand what to pass to the setupUI() function to get the QGroupBox to show on the tab widget. Anyone know what I am doing wrong?