43 lines
887 B
C++
43 lines
887 B
C++
|
|
#include "monitorAttributeDlg.h"
|
||
|
|
#include "monitorToolBox.h"
|
||
|
|
#include <QVBoxLayout>
|
||
|
|
|
||
|
|
MonitorAttributeDlg::MonitorAttributeDlg(QWidget* parent)
|
||
|
|
: QDialog(parent)
|
||
|
|
,_pLayout(nullptr)
|
||
|
|
{
|
||
|
|
initial();
|
||
|
|
}
|
||
|
|
|
||
|
|
MonitorAttributeDlg::~MonitorAttributeDlg()
|
||
|
|
{
|
||
|
|
|
||
|
|
}
|
||
|
|
|
||
|
|
void MonitorAttributeDlg::initial()
|
||
|
|
{
|
||
|
|
_pLayout = new QVBoxLayout(this);
|
||
|
|
}
|
||
|
|
|
||
|
|
void MonitorAttributeDlg::setCurAttribute(MonitorToolBox* pBox)
|
||
|
|
{
|
||
|
|
if(_pLayout->count() == 0){ //当前无对象,添加
|
||
|
|
_pLayout->addWidget(pBox);
|
||
|
|
}
|
||
|
|
else{
|
||
|
|
clearCurAttribute();
|
||
|
|
_pLayout->addWidget(pBox);
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
void MonitorAttributeDlg::clearCurAttribute() //移除当前属性
|
||
|
|
{
|
||
|
|
for (int i = 0; i < _pLayout->count(); ++i) {
|
||
|
|
QLayoutItem* item = _pLayout->itemAt(i);
|
||
|
|
auto pWidget = item->widget();
|
||
|
|
if(pWidget){
|
||
|
|
_pLayout->removeWidget(pWidget);
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|