{
ui.setupUi( this );
setCentralWidget( m_pCentralWidget );
// create tabs
ui.tabWidget = m_tabWidget;
m_tabDMX = new DMXTable( this );
ui.tabWidget->addTab( m_tabDMX, tr("First Tab") );
m_tabAll = new AllTab( this );
ui.tabWidget->addTab( m_tabAll, tr("Second Tab") );
// Load frame with required stuff; Place widgets in frame; left to right
qFrame
->setFrameRect
( QRect( 0,
0,
0,
0 ) );
// Checkbox in frame
m_onlineChk
= new QCheckBox( "Show Online Table ", qFrame
);
m_onlineChk->setToolTip( "Show/Hide Online Table" );
connect( m_onlineChk, SIGNAL( clicked() ), this, SLOT( onlineClicked() ) );
m_onlineChk->setCheckState( Qt::Checked );
frameLayout
->setSizeConstraint
( QLayout::SetMaximumSize );
frameLayout->addWidget( m_onlineChk, 0, Qt::AlignRight );
frameLayout->insertStretch( 0, 0 );
qFrame->setLayout( frameLayout );
// Put everything onto the main window.
// Tab widget is 1st
m_centralLayout->addWidget( m_tabWidget, 1, 0, 1, 1);
// Frame is on bottom (just above the status bar)
m_centralLayout->addWidget( qFrame, 2, 0, 1, 1 );
m_pCentralWidget->setLayout( m_centralLayout );
m_pExitAct
= new QAction( tr
("E&xit"),
this );
m_pExitAct->setShortcut( tr("Ctrl+Q") );
connect( m_pExitAct, SIGNAL(triggered()), this, SLOT(close()) );
m_pFileMenu = menuBar()->addMenu( tr("&File") );
m_pFileMenu->addAction( m_pExitAct );
show();
}
MainWin::MainWin( QWidget* parent, Qt::WFlags flags ) : QMainWindow( parent, flags )
{
ui.setupUi( this );
m_pCentralWidget = new QWidget;
setCentralWidget( m_pCentralWidget );
// create tabs
m_tabWidget = new QTabWidget( this );
ui.tabWidget = m_tabWidget;
m_tabDMX = new DMXTable( this );
ui.tabWidget->addTab( m_tabDMX, tr("First Tab") );
m_tabAll = new AllTab( this );
ui.tabWidget->addTab( m_tabAll, tr("Second Tab") );
// Load frame with required stuff; Place widgets in frame; left to right
QFrame* qFrame = new QFrame( this );
qFrame->setFrameRect( QRect( 0, 0, 0, 0 ) );
qFrame->setFrameStyle( QFrame::Box | QFrame::Plain );
// Checkbox in frame
m_onlineChk = new QCheckBox( "Show Online Table ", qFrame );
m_onlineChk->setToolTip( "Show/Hide Online Table" );
connect( m_onlineChk, SIGNAL( clicked() ), this, SLOT( onlineClicked() ) );
m_onlineChk->setCheckState( Qt::Checked );
QHBoxLayout* frameLayout = new QHBoxLayout( qFrame );
frameLayout->setSizeConstraint( QLayout::SetMaximumSize );
frameLayout->addWidget( m_onlineChk, 0, Qt::AlignRight );
frameLayout->insertStretch( 0, 0 );
qFrame->setLayout( frameLayout );
// Put everything onto the main window.
m_centralLayout = new QGridLayout;
// Tab widget is 1st
m_centralLayout->addWidget( m_tabWidget, 1, 0, 1, 1);
// Frame is on bottom (just above the status bar)
m_centralLayout->addWidget( qFrame, 2, 0, 1, 1 );
m_pCentralWidget->setLayout( m_centralLayout );
m_pExitAct = new QAction( tr("E&xit"), this );
m_pExitAct->setShortcut( tr("Ctrl+Q") );
connect( m_pExitAct, SIGNAL(triggered()), this, SLOT(close()) );
m_pFileMenu = menuBar()->addMenu( tr("&File") );
m_pFileMenu->addAction( m_pExitAct );
show();
}
To copy to clipboard, switch view to plain text mode
// DMX Table Tab Class
{
m_parent = reinterpret_cast<MainWin*>( pParent );
ui.setupUi( m_parent );
// ui.setupUi( this );
m_onlineGroupBox
= new QGroupBox( tr
("Online Devices") );
sLabels << "Status" << "Name" << "Type" << "IP Address" << "Model Name";
m_pOnlineTable->setHorizontalHeaderLabels( sLabels );
m_pOnlineTable->setColumnWidth( 0, 40 );
m_pOnlineTable->setColumnWidth( 1, 150 );
m_pOnlineTable->setColumnWidth( 2, 130 );
m_pOnlineTable->setColumnWidth( 3, 120 );
m_pOnlineTable->setColumnWidth( 4, 200 );
pTableArea->setWidgetResizable( true );
pTableArea->setWidget( m_pOnlineTable );
layout->addWidget( pTableArea, 0, 0 );
m_onlineGroupBox->setLayout( layout );
m_onlineGroupBox->show();
}
// DMX Table Tab Class
DMXTable::DMXTable( QWidget* pParent ) : QWidget( /*pParent*/ )
{
m_parent = reinterpret_cast<MainWin*>( pParent );
ui.setupUi( m_parent );
// ui.setupUi( this );
m_onlineGroupBox = new QGroupBox( tr("Online Devices") );
QScrollArea* pTableArea = new QScrollArea;
m_pOnlineTable = new QTableWidget( 1, 5, m_parent );
QStringList sLabels;
sLabels << "Status" << "Name" << "Type" << "IP Address" << "Model Name";
m_pOnlineTable->setHorizontalHeaderLabels( sLabels );
m_pOnlineTable->setColumnWidth( 0, 40 );
m_pOnlineTable->setColumnWidth( 1, 150 );
m_pOnlineTable->setColumnWidth( 2, 130 );
m_pOnlineTable->setColumnWidth( 3, 120 );
m_pOnlineTable->setColumnWidth( 4, 200 );
pTableArea->setWidgetResizable( true );
pTableArea->setWidget( m_pOnlineTable );
QGridLayout* layout = new QGridLayout;
layout->addWidget( pTableArea, 0, 0 );
m_onlineGroupBox->setLayout( layout );
m_onlineGroupBox->show();
}
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 *'.
Bookmarks