61 lines
1.2 KiB
C++
61 lines
1.2 KiB
C++
#include "QMyStackedWidget.h"
|
|
|
|
QMyStackedWidget::QMyStackedWidget(QWidget *parent)
|
|
: QStackedWidget(parent)
|
|
{
|
|
//ui.setupUi(this);
|
|
}
|
|
|
|
QMyStackedWidget::~QMyStackedWidget()
|
|
{
|
|
|
|
}
|
|
|
|
void QMyStackedWidget::addWidget(QWidget * pWidget, const QString & strWidgetName)
|
|
{
|
|
//防御性验证
|
|
if ( pWidget == NULL )
|
|
{
|
|
return;
|
|
}
|
|
|
|
m_subWidgetTable[strWidgetName] = pWidget;
|
|
|
|
QStackedWidget::addWidget( pWidget );
|
|
}
|
|
|
|
void QMyStackedWidget::removeWidget(QWidget * pWidget)
|
|
{
|
|
const QString & strWidgetName = m_subWidgetTable.key( pWidget );
|
|
|
|
//判断一下列表中是否有这个widget
|
|
if ( strWidgetName.length() != 0 )
|
|
{
|
|
QStackedWidget::removeWidget( pWidget );
|
|
m_subWidgetTable.remove( strWidgetName );
|
|
}
|
|
}
|
|
|
|
void QMyStackedWidget::removeWidget(const QString & strWidgetName)
|
|
{
|
|
if ( m_subWidgetTable.contains(strWidgetName) == true )
|
|
{
|
|
QStackedWidget::removeWidget( m_subWidgetTable[strWidgetName] );
|
|
|
|
m_subWidgetTable.remove( strWidgetName );
|
|
}
|
|
}
|
|
|
|
void QMyStackedWidget::showWidget(const QString & strWidgetName)
|
|
{
|
|
if ( m_subWidgetTable.contains(strWidgetName) == true )
|
|
{
|
|
setCurrentWidget( m_subWidgetTable[strWidgetName] );
|
|
}
|
|
}
|
|
|
|
void QMyStackedWidget::showWidget(int index)
|
|
{
|
|
|
|
}
|