修改状态显示,添加组别
This commit is contained in:
@@ -2,9 +2,6 @@
|
||||
|
||||
StateWidget::StateWidget(int flag,int index,QWidget *parent) : QWidget(parent)
|
||||
{
|
||||
int w = 150;
|
||||
int h = 20;
|
||||
|
||||
gridlayout = new QGridLayout(this);
|
||||
gridlayout->setMargin(0);
|
||||
gridlayout->setVerticalSpacing(6);
|
||||
@@ -14,15 +11,15 @@ StateWidget::StateWidget(int flag,int index,QWidget *parent) : QWidget(parent)
|
||||
title->setAlignment(Qt::AlignLeft | Qt::AlignVCenter);
|
||||
title->setFixedSize(w/2,h);
|
||||
|
||||
gridlayout->addWidget(title,0,0);
|
||||
gridlayout->addWidget(title,0,0,1,1);
|
||||
|
||||
if(flag == 0)
|
||||
{
|
||||
label = new QLabel("0");
|
||||
label->setAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
|
||||
label->setFixedSize(w,h);
|
||||
setColor(label,state::gray);
|
||||
gridlayout->addWidget(label,0,1);
|
||||
label->setFixedSize(w/2,h);
|
||||
setColor(state::gray);
|
||||
gridlayout->addWidget(label,0,1,1,1);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -30,9 +27,11 @@ StateWidget::StateWidget(int flag,int index,QWidget *parent) : QWidget(parent)
|
||||
bar->setAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
|
||||
bar->setRange(0,100);
|
||||
bar->setValue(0);
|
||||
bar->setFixedSize(w,h);
|
||||
gridlayout->addWidget(bar,0,1);
|
||||
bar->setFixedSize(w/2,h);
|
||||
gridlayout->addWidget(bar,0,1,1,1);
|
||||
}
|
||||
|
||||
this->setLayout(gridlayout);
|
||||
}
|
||||
|
||||
StateWidget::StateWidget(int flag, QString t,QVariant v,state s,int index, QWidget *parent) : QWidget(parent)
|
||||
@@ -40,9 +39,6 @@ StateWidget::StateWidget(int flag, QString t,QVariant v,state s,int index, QWidg
|
||||
|
||||
id = index;
|
||||
|
||||
int w = 150;
|
||||
int h = 20;
|
||||
|
||||
gridlayout = new QGridLayout(this);
|
||||
gridlayout->setMargin(0);
|
||||
gridlayout->setVerticalSpacing(6);
|
||||
@@ -52,51 +48,105 @@ StateWidget::StateWidget(int flag, QString t,QVariant v,state s,int index, QWidg
|
||||
title->setAlignment(Qt::AlignLeft | Qt::AlignVCenter);
|
||||
title->setFixedSize(w/2,h);
|
||||
|
||||
gridlayout->addWidget(title,0,0);
|
||||
gridlayout->addWidget(title,0,0,1,1);
|
||||
|
||||
if(flag == 0)
|
||||
{
|
||||
label = new QLabel(v.toString());
|
||||
label->setAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
|
||||
label->setFixedSize(w,h);
|
||||
setColor(label,s);
|
||||
gridlayout->addWidget(label,0,1);
|
||||
label->setFixedSize(w/2,h);
|
||||
setColor(s);
|
||||
gridlayout->addWidget(label,0,1,1,1);
|
||||
}
|
||||
else
|
||||
{
|
||||
bar = new QProgressBar();
|
||||
bar->setFormat("%v");
|
||||
bar->setAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
|
||||
bar->setRange(0,100);
|
||||
bar->setValue(v.toDouble());
|
||||
bar->setFixedSize(w,h);
|
||||
gridlayout->addWidget(bar,0,1);
|
||||
bar->setFixedSize(w/2,h);
|
||||
gridlayout->addWidget(bar,0,1,1,1);
|
||||
}
|
||||
|
||||
this->setLayout(gridlayout);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
StateWidget::~StateWidget()
|
||||
{
|
||||
if(title)
|
||||
{
|
||||
delete title;
|
||||
}
|
||||
|
||||
if(label)
|
||||
{
|
||||
delete label;
|
||||
}
|
||||
|
||||
if(bar)
|
||||
{
|
||||
delete bar;
|
||||
}
|
||||
|
||||
if(gridlayout)
|
||||
{
|
||||
delete gridlayout;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
void StateWidget::setColor(QWidget *w,state s)
|
||||
void StateWidget::setColor(state s)
|
||||
{
|
||||
w->setProperty("state",s);
|
||||
w->style()->unpolish(w);
|
||||
w->style()->polish(w);
|
||||
if(label)
|
||||
{
|
||||
label->setProperty("state",s);
|
||||
label->style()->unpolish(label);
|
||||
label->style()->polish(label);
|
||||
}
|
||||
|
||||
if(bar)
|
||||
{
|
||||
bar->setProperty("state",s);
|
||||
bar->style()->unpolish(bar);
|
||||
bar->style()->polish(bar);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void StateWidget::setValue(QLabel *w,QString s)
|
||||
void StateWidget::setValue(QString s)
|
||||
{
|
||||
w->setText(s);
|
||||
if(label)
|
||||
{
|
||||
label->setText(s);
|
||||
}
|
||||
|
||||
if(bar)
|
||||
{
|
||||
bar->setValue(s.toDouble());
|
||||
}
|
||||
}
|
||||
|
||||
void StateWidget::setRange(double m_min,double m_max)
|
||||
{
|
||||
min = m_min;
|
||||
max = m_max;
|
||||
|
||||
if(bar)
|
||||
{
|
||||
bar->setRange(m_min,m_max);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user