58 lines
1.3 KiB
C++
58 lines
1.3 KiB
C++
#include "monitorToolBox.h"
|
|
#include "monitorToolPage.h"
|
|
|
|
#include <QVBoxLayout>
|
|
#include <QSpacerItem>
|
|
|
|
MonitorToolBox::MonitorToolBox(QWidget *parent) :
|
|
QScrollArea(parent)
|
|
,m_pContentVBoxLayout(nullptr)
|
|
,_container(nullptr)
|
|
{
|
|
_container = new QWidget;
|
|
m_pContentVBoxLayout = new QVBoxLayout(_container);
|
|
setWidget(_container);
|
|
m_pContentVBoxLayout->setContentsMargins(0, 0, 0, 0);
|
|
setWidgetResizable(true);
|
|
}
|
|
|
|
MonitorToolBox::~MonitorToolBox()
|
|
{
|
|
|
|
}
|
|
|
|
void MonitorToolBox::addWidget(const QString &title, QWidget *pWidget)
|
|
{
|
|
MonitorToolPage *page = new MonitorToolPage(this);
|
|
page->addWidget(title, pWidget);
|
|
|
|
m_pContentVBoxLayout->addWidget(page);
|
|
//pLayout->insertWidget(0,page);
|
|
//pLayout->addStretch(0);
|
|
m_mapWidget.insert(title,page);
|
|
}
|
|
|
|
void MonitorToolBox::removeWidget(const QString &title)
|
|
{
|
|
bool bExist = m_mapWidget.contains(title);
|
|
if(bExist)
|
|
{
|
|
QWidget *pWidget = m_mapWidget.take(title);
|
|
if(pWidget)
|
|
{
|
|
MonitorToolPage* toolPage = dynamic_cast<MonitorToolPage*>(pWidget);
|
|
if(toolPage)
|
|
{
|
|
m_pContentVBoxLayout->removeWidget(toolPage);
|
|
delete toolPage;
|
|
}
|
|
|
|
}
|
|
}
|
|
else
|
|
{
|
|
//cerr
|
|
}
|
|
|
|
}
|