状态显示完成
This commit is contained in:
@@ -1,8 +1,24 @@
|
||||
#include "StateGroup.h"
|
||||
|
||||
StateGroup::StateGroup(QWidget *parent) : QWidget(parent)
|
||||
StateGroup::StateGroup(int index,QWidget *parent) : QWidget(parent)
|
||||
{
|
||||
id = index;
|
||||
|
||||
toplayout = new QGridLayout(this);
|
||||
this->setLayout(toplayout);
|
||||
toplayout->setMargin(0);
|
||||
|
||||
box = new QGroupBox(this);
|
||||
|
||||
toplayout->addWidget(box);
|
||||
|
||||
|
||||
layout = new QGridLayout(box);
|
||||
|
||||
layout->setMargin(3);
|
||||
layout->setHorizontalSpacing(6);
|
||||
|
||||
box->setLayout(layout);
|
||||
}
|
||||
|
||||
|
||||
@@ -11,17 +27,24 @@ StateGroup::~StateGroup()
|
||||
foreach (StateWidget * w, ItemList) {
|
||||
delete w;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void StateGroup::addItem(StateWidget * w)
|
||||
{
|
||||
ItemList.insert(ItemList.size(),w);//逐渐往上加
|
||||
|
||||
qDebug() << "w->ID()" << w->ID();
|
||||
if(layout)
|
||||
{
|
||||
if(w->ID() >= 0)
|
||||
{
|
||||
layout->addWidget(w,w->ID(),0,1,1);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//检查界面,添加到界面
|
||||
|
||||
updateUI();
|
||||
}
|
||||
|
||||
void StateGroup::addItems(QMap<int, StateWidget *> list)
|
||||
@@ -31,6 +54,26 @@ void StateGroup::addItems(QMap<int, StateWidget *> list)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void StateGroup::removeItem(int index)
|
||||
{
|
||||
if(ItemList.contains(index))
|
||||
{
|
||||
StateWidget *w = ItemList.value(index);
|
||||
|
||||
delete w;
|
||||
}
|
||||
}
|
||||
|
||||
void StateGroup::removeItem(StateWidget * w)
|
||||
{
|
||||
if(ItemList.values().contains(w))
|
||||
{
|
||||
delete w;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void StateGroup::setValue(int index,QString value)
|
||||
{
|
||||
if(ItemList.contains(index))
|
||||
@@ -39,7 +82,7 @@ void StateGroup::setValue(int index,QString value)
|
||||
}
|
||||
}
|
||||
|
||||
void StateGroup::setState(int index,StateWidget::state s)
|
||||
void StateGroup::setColor(int index,StateWidget::state s)
|
||||
{
|
||||
if(ItemList.contains(index))
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user