Thank you for trying to help a Qt novice with this problem. I've learned a lot from this forum already.
I don't override the paint event, although we ARE using the Arthur style.
The classes are defined as such:
{
public:
{
// Only change the background color of the selected tab
pal.
setColor( QPalette::Base, COLOR_ManageBkg
);
tabBar()->setPalette( pal );
}
}; // class EditTabWidget : public QTabWidget
{
Q_OBJECT
public:
void ApplyUpdates( void );
void accept( void );
void reject( void );
private slots:
void on_nameEdt_editingFinished( void );
void on_ipAddrEdt_textChanged( const QString& sIP );
void on_subnetMaskEdt_textChanged( const QString& sIP );
void on_defIPEdt_textChanged( const QString& sIP );
void on_tftpSrvrIPEdt_textChanged( const QString& sIP );
void on_dynamicRadBtn_toggled( bool bState );
void on_staticRadBtn_toggled( bool bState );
void on_editIPBtn_clicked( void );
void on_resetBtn_clicked( void );
void on_identifyBtn_clicked( void );
void on_dwnldBtn_clicked( void );
void on_rebootBtn_clicked( void );
void on_clearBtn_clicked( void );
protected:
bool validateIPAddress( const QString& sIP );
public:
Ui::ACNCfgGenDlg ui;
private:
EditACNDlg * m_parent;
CController * m_pController;
CACNGateway * m_pNode;
}; // class ACNGenTab : public QWidget
///////////////////////////////////////////////////////////////////////////////
// ACN Port Properties Tab Class
{
Q_OBJECT
public:
ACNPortsTab
( QWidget* pParent
= 0 );
void InitializeTabUI( void );
void ApplyUpdates( void );
void showPriorityDialog( int nPort );
void showAIPDialog( int nPort );
void accept( void );
void reject( void );
protected:
void ApplyPort1Updates( void );
void ApplyPort2Updates( void );
void ApplyPort3Updates( void );
void ApplyPort4Updates( void );
private slots:
// ... lots of slots to record and/or validate UI data changes
public:
Ui::ACNCfgPortsDlg ui;
bool m_bIsInitialized;
private:
EditACNDlg * m_parent;
CController * m_pController;
CACNGateway * m_pNode;
}; // class ACNPortsTab : public QWidget
///////////////////////////////////////////////////////////////////////////////
// ACN AIP Properties Tab Class
{
Q_OBJECT
public:
ACNAIPTab
( CACNGateway
* pNode, MainWin
* pMainWin,
QWidget* pParent
= 0,
int nPort
= -1 );
void InitializeTabUI( void );
int GetCurrentPort( void );
QTableWidget* GetCurrentTable
( void ) { return m_pCurrTable;
}
void ApplyUpdates( void );
void accept( void );
void reject( void );
private slots:
void on_copyBtn_clicked();
void on_oneToOneBtn_clicked( void );
void on_rangeBtn_clicked( void );
void on_clearBtn_clicked( void );
void portCboIdxChange( int nIndex );
void on_aipChk_stateChanged( int nState );
void updateFreeChannelNum( void );
public:
Ui::ACNAIPDlg ui;
MainWin* m_pMainWin;
bool m_bIsInitialized;
private:
EditACNDlg * m_parent;
CController * m_pController;
CACNGateway * m_pNode;
bool m_bOnline;
int m_nPort;
bool m_bPort1AIPEnabled;
bool m_bPort2AIPEnabled;
bool m_bPort3AIPEnabled;
bool m_bPort4AIPEnabled;
}; // class ACNAIPTab : public QWidget
///////////////////////////////////////////////////////////////////////////////
// ACN About Properties Tab Class
{
Q_OBJECT
public:
ACNAboutTab
( QWidget* pParent
= 0 );
void InitializeTabUI( void );
void accept( void ) {}
void reject( void ) {}
public:
Ui::ACNCfgRODlg ui;
bool m_bIsInitialized;
private:
EditACNDlg* m_parent;
}; // class ACNAboutTab : public QWidget
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
// Edit ACN Properties Class
{
Q_OBJECT
public:
EditACNDlg( MainWin* pMainWin, const int type, void* pData, bool bIsCfgTable,
bool bAllowIPEdit,
bool bOnlineUpdate
= true,
QWidget* pParent
= 0 );
virtual ~EditACNDlg();
// Return current values for Name, IPAddress and boundNode.
void GetCellUpdates( QString& sName, QString& sIP,
uint1& nP1Mode, uint1& nP2Mode, uint1& nP3Mode, uint1& nP4Mode,
uint4& nP1Univ, uint4& nP2Univ, uint4& nP3Univ, uint4& nP4Univ );
private slots:
void on_okPushButton_clicked() { accept(); }
void on_cancelPushButton_clicked() { reject(); }
void setFocusInTab( int nTabIndex );
public:
MainWin * m_pMainWin;
CController * m_pController;
CACNGateway * m_pNode;
bool m_bAllowIPEdit;
int m_devType;
bool m_bIsDynamicIP;
// ...lots more data members
bool m_bOnlineUpdate;
bool m_bIsCfgTable;
bool m_bInitializing;
private:
void accept( void );
void reject( void );
Ui::EditPropsDlg ui;
EditTabWidget* m_tabWidget;
ACNGenTab* m_tabACN_Gen;
ACNPortsTab* m_tabACN_Ports;
ACNAIPTab* m_tabACN_AIP;
ACNAboutTab* m_tabACN_About;
}; // class EditACNDlg : public QDialog
class EditTabWidget : public QTabWidget
{
public:
EditTabWidget( QWidget *pParent = 0 ) : QTabWidget( pParent )
{
// Only change the background color of the selected tab
QPalette pal = tabBar()->palette();
pal.setColor( QPalette::Base, COLOR_ManageBkg );
tabBar()->setPalette( pal );
}
}; // class EditTabWidget : public QTabWidget
class ACNGenTab : public QWidget
{
Q_OBJECT
public:
ACNGenTab( QWidget* pParent = 0 );
void ApplyUpdates( void );
void accept( void );
void reject( void );
private slots:
void on_nameEdt_editingFinished( void );
void on_ipAddrEdt_textChanged( const QString& sIP );
void on_subnetMaskEdt_textChanged( const QString& sIP );
void on_defIPEdt_textChanged( const QString& sIP );
void on_tftpSrvrIPEdt_textChanged( const QString& sIP );
void on_dynamicRadBtn_toggled( bool bState );
void on_staticRadBtn_toggled( bool bState );
void on_editIPBtn_clicked( void );
void on_resetBtn_clicked( void );
void on_identifyBtn_clicked( void );
void on_dwnldBtn_clicked( void );
void on_rebootBtn_clicked( void );
void on_clearBtn_clicked( void );
protected:
bool validateIPAddress( const QString& sIP );
public:
Ui::ACNCfgGenDlg ui;
private:
EditACNDlg * m_parent;
CController * m_pController;
CACNGateway * m_pNode;
}; // class ACNGenTab : public QWidget
///////////////////////////////////////////////////////////////////////////////
// ACN Port Properties Tab Class
class ACNPortsTab : public QWidget
{
Q_OBJECT
public:
ACNPortsTab( QWidget* pParent = 0 );
void InitializeTabUI( void );
void ApplyUpdates( void );
void showPriorityDialog( int nPort );
void showAIPDialog( int nPort );
void accept( void );
void reject( void );
protected:
void ApplyPort1Updates( void );
void ApplyPort2Updates( void );
void ApplyPort3Updates( void );
void ApplyPort4Updates( void );
private slots:
// ... lots of slots to record and/or validate UI data changes
public:
Ui::ACNCfgPortsDlg ui;
bool m_bIsInitialized;
private:
EditACNDlg * m_parent;
CController * m_pController;
CACNGateway * m_pNode;
}; // class ACNPortsTab : public QWidget
///////////////////////////////////////////////////////////////////////////////
// ACN AIP Properties Tab Class
class ACNAIPTab : public QWidget
{
Q_OBJECT
public:
ACNAIPTab( CACNGateway* pNode, MainWin* pMainWin, QWidget* pParent = 0, int nPort = -1 );
void InitializeTabUI( void );
int GetCurrentPort( void );
QString GetUniverseNum( void );
QTableWidget* GetCurrentTable( void ) { return m_pCurrTable; }
void ApplyUpdates( void );
void accept( void );
void reject( void );
private slots:
void on_copyBtn_clicked();
void on_oneToOneBtn_clicked( void );
void on_rangeBtn_clicked( void );
void on_clearBtn_clicked( void );
void portCboIdxChange( int nIndex );
void on_aipChk_stateChanged( int nState );
void updateFreeChannelNum( void );
public:
Ui::ACNAIPDlg ui;
MainWin* m_pMainWin;
bool m_bIsInitialized;
private:
EditACNDlg * m_parent;
CController * m_pController;
CACNGateway * m_pNode;
bool m_bOnline;
int m_nPort;
QTableWidget* m_pCurrTable;
bool m_bPort1AIPEnabled;
bool m_bPort2AIPEnabled;
bool m_bPort3AIPEnabled;
bool m_bPort4AIPEnabled;
}; // class ACNAIPTab : public QWidget
///////////////////////////////////////////////////////////////////////////////
// ACN About Properties Tab Class
class ACNAboutTab : public QWidget
{
Q_OBJECT
public:
ACNAboutTab( QWidget* pParent = 0 );
void InitializeTabUI( void );
void accept( void ) {}
void reject( void ) {}
public:
Ui::ACNCfgRODlg ui;
bool m_bIsInitialized;
private:
EditACNDlg* m_parent;
}; // class ACNAboutTab : public QWidget
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
// Edit ACN Properties Class
class EditACNDlg : public QDialog
{
Q_OBJECT
public:
EditACNDlg( MainWin* pMainWin, const int type, void* pData, bool bIsCfgTable,
bool bAllowIPEdit, bool bOnlineUpdate = true, QWidget* pParent = 0 );
virtual ~EditACNDlg();
// Return current values for Name, IPAddress and boundNode.
void GetCellUpdates( QString& sName, QString& sIP,
uint1& nP1Mode, uint1& nP2Mode, uint1& nP3Mode, uint1& nP4Mode,
uint4& nP1Univ, uint4& nP2Univ, uint4& nP3Univ, uint4& nP4Univ );
private slots:
void on_okPushButton_clicked() { accept(); }
void on_cancelPushButton_clicked() { reject(); }
void setFocusInTab( int nTabIndex );
public:
MainWin * m_pMainWin;
CController * m_pController;
CACNGateway * m_pNode;
bool m_bAllowIPEdit;
int m_devType;
QString m_sName;
QString m_sCID;
QString m_sIPAddr;
bool m_bIsDynamicIP;
QString m_sSubnetMask;
QString m_sTFTPIP;
// ...lots more data members
bool m_bOnlineUpdate;
bool m_bIsCfgTable;
bool m_bInitializing;
private:
void accept( void );
void reject( void );
Ui::EditPropsDlg ui;
EditTabWidget* m_tabWidget;
ACNGenTab* m_tabACN_Gen;
ACNPortsTab* m_tabACN_Ports;
ACNAIPTab* m_tabACN_AIP;
ACNAboutTab* m_tabACN_About;
}; // class EditACNDlg : public QDialog
To copy to clipboard, switch view to plain text mode
This is the constructor of the dialog
EditACNDlg::EditACNDlg( MainWin* pMainWin, const int type, void* pData,
bool bIsCfgTable, bool bAllowIPEdit,
{
// Initialize class member variables
m_pMainWin = pMainWin;
m_pController = m_pMainWin->m_pController;
m_devType = type;
m_bOnlineUpdate = bOnlineUpdate;
m_bAllowIPEdit = bAllowIPEdit;
m_bIsCfgTable = bIsCfgTable;
m_bInitializing = true;
m_pNode = reinterpret_cast<CACNGateway*>( pData );
if ( m_pNode == NULL )
return; // ERROR: device not found in online map
// Setup the dialog UI
ui.setupUi( this );
setFixedSize( 579, 641 );
// Setup the QTabWidget
m_tabWidget = new EditTabWidget( this );
m_tabWidget
->setTabShape
( QTabWidget::Triangular );
m_tabWidget->setFixedSize( 560, 565 );
palette.setColor( m_tabWidget->backgroundRole(), Qt::white );
m_tabWidget->setPalette( palette );
connect( m_tabWidget, SIGNAL( currentChanged( int ) ), this, SLOT( setFocusInTab( int ) ) );
// Setup the individual tab-specific widgets
m_tabACN_Gen = new ACNGenTab( this );
m_tabWidget->addTab( m_tabACN_Gen, tr(GENERAL_TAB.toAscii().data()) );
m_tabACN_Ports = new ACNPortsTab( this );
m_tabWidget->addTab( m_tabACN_Ports, tr(PORTS_TAB.toAscii().data()) );
m_tabACN_AIP = new ACNAIPTab( m_pNode, m_pMainWin, this );
m_tabWidget->addTab( m_tabACN_AIP, tr("AIP") );
if ( !m_bIsCfgTable )
{
m_tabACN_About = new ACNAboutTab( this );
m_tabWidget->addTab( m_tabACN_About, tr(ABOUT_TAB.toAscii().data()) );
}
// Layout the Dialog elements
mainLayout->addWidget( m_tabWidget );
mainLayout->addSpacing( 70 ); // Force tabs to top of dialog
setLayout( mainLayout );
setWindowTitle( tr("DMX Gateway Configuration") );
// Set focus on 1st editable element on the first tab
m_tabACN_Gen->ui.nameEdt->setFocus();
m_tabACN_Gen->ui.nameEdt->setCursorPosition( 0 );
// Set the "What's This?" text
m_tabWidget->setWhatsThis( WT_ACN_TAB );
ui.okPushButton->setWhatsThis( WT_OK_BTN );
ui.cancelPushButton->setWhatsThis( WT_CANCEL_BTN );
m_bInitializing = false;
} // EditACNDlg::EditACNDlg(
EditACNDlg::EditACNDlg( MainWin* pMainWin, const int type, void* pData,
bool bIsCfgTable, bool bAllowIPEdit,
bool bOnlineUpdate, QWidget* pParent ) : QDialog( pParent )
{
// Initialize class member variables
m_pMainWin = pMainWin;
m_pController = m_pMainWin->m_pController;
m_devType = type;
m_bOnlineUpdate = bOnlineUpdate;
m_bAllowIPEdit = bAllowIPEdit;
m_bIsCfgTable = bIsCfgTable;
m_bInitializing = true;
m_pNode = reinterpret_cast<CACNGateway*>( pData );
if ( m_pNode == NULL )
return; // ERROR: device not found in online map
// Setup the dialog UI
ui.setupUi( this );
setFixedSize( 579, 641 );
// Setup the QTabWidget
m_tabWidget = new EditTabWidget( this );
m_tabWidget->setTabShape( QTabWidget::Triangular );
m_tabWidget->setFixedSize( 560, 565 );
QPalette palette;
palette.setColor( m_tabWidget->backgroundRole(), Qt::white );
m_tabWidget->setPalette( palette );
connect( m_tabWidget, SIGNAL( currentChanged( int ) ), this, SLOT( setFocusInTab( int ) ) );
// Setup the individual tab-specific widgets
m_tabACN_Gen = new ACNGenTab( this );
m_tabWidget->addTab( m_tabACN_Gen, tr(GENERAL_TAB.toAscii().data()) );
m_tabACN_Ports = new ACNPortsTab( this );
m_tabWidget->addTab( m_tabACN_Ports, tr(PORTS_TAB.toAscii().data()) );
m_tabACN_AIP = new ACNAIPTab( m_pNode, m_pMainWin, this );
m_tabWidget->addTab( m_tabACN_AIP, tr("AIP") );
if ( !m_bIsCfgTable )
{
m_tabACN_About = new ACNAboutTab( this );
m_tabWidget->addTab( m_tabACN_About, tr(ABOUT_TAB.toAscii().data()) );
}
// Layout the Dialog elements
QVBoxLayout* mainLayout = new QVBoxLayout;
mainLayout->addWidget( m_tabWidget );
mainLayout->addSpacing( 70 ); // Force tabs to top of dialog
setLayout( mainLayout );
setWindowTitle( tr("DMX Gateway Configuration") );
// Set focus on 1st editable element on the first tab
m_tabACN_Gen->ui.nameEdt->setFocus();
m_tabACN_Gen->ui.nameEdt->setCursorPosition( 0 );
// Set the "What's This?" text
m_tabWidget->setWhatsThis( WT_ACN_TAB );
ui.okPushButton->setWhatsThis( WT_OK_BTN );
ui.cancelPushButton->setWhatsThis( WT_CANCEL_BTN );
m_bInitializing = false;
} // EditACNDlg::EditACNDlg(
To copy to clipboard, switch view to plain text mode
This is the constructor of one of the pages being drawn on a tab.
{
m_parent = reinterpret_cast<EditACNDlg*>( pParent );
m_bIsInitialized = false;
ui.setupUi( this );
InitializeTabUI(); // This call initializes UI elements & fills in data
} // ACNPortsTab::ACNPortsTab(
ACNPortsTab::ACNPortsTab( QWidget* pParent ) : QWidget( /*pParent*/ )
{
m_parent = reinterpret_cast<EditACNDlg*>( pParent );
m_bIsInitialized = false;
ui.setupUi( this );
InitializeTabUI(); // This call initializes UI elements & fills in data
} // ACNPortsTab::ACNPortsTab(
To copy to clipboard, switch view to plain text mode
- marcel, I thought that by using QTabWidget all non-visible forms were hidden by default. The constructor would set up the ui elements (and maybe fill in data) but no drawing would occur until that tab was selected, no?
- Previously I updated the form data in each particular forms' constructor. I now delay that until the form is selected the first time. This seems to make little noticable difference.
- My most complicated form contains 50+ items (QLineEdit, QComboBox, QPushButton, QLabel).
Thanks again for your help!
Bookmarks