添加状态生成
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
#include "StateWidget.h"
|
||||
|
||||
StateWidget::StateWidget(int flag,QWidget *parent) : QWidget(parent)
|
||||
StateWidget::StateWidget(int flag,int index,QWidget *parent) : QWidget(parent)
|
||||
{
|
||||
int w = 150;
|
||||
int h = 20;
|
||||
@@ -21,7 +21,7 @@ StateWidget::StateWidget(int flag,QWidget *parent) : QWidget(parent)
|
||||
label = new QLabel("0");
|
||||
label->setAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
|
||||
label->setFixedSize(w,h);
|
||||
setColor(label,state::inital);
|
||||
setColor(label,state::gray);
|
||||
gridlayout->addWidget(label,0,1);
|
||||
}
|
||||
else
|
||||
@@ -35,8 +35,11 @@ StateWidget::StateWidget(int flag,QWidget *parent) : QWidget(parent)
|
||||
}
|
||||
}
|
||||
|
||||
StateWidget::StateWidget(int flag, QString t,QVariant v,state s, QWidget *parent) : QWidget(parent)
|
||||
StateWidget::StateWidget(int flag, QString t,QVariant v,state s,int index, QWidget *parent) : QWidget(parent)
|
||||
{
|
||||
|
||||
id = index;
|
||||
|
||||
int w = 150;
|
||||
int h = 20;
|
||||
|
||||
|
||||
@@ -24,19 +24,33 @@ class StateWidget :public QWidget
|
||||
public:
|
||||
|
||||
enum state{
|
||||
success = 0,
|
||||
failure = 1,
|
||||
warning = 2,
|
||||
inital = 3,
|
||||
green = 0,
|
||||
rad = 1,
|
||||
orange = 2,
|
||||
gray = 3,
|
||||
};
|
||||
|
||||
explicit StateWidget(int flag, QWidget *parent = nullptr);
|
||||
explicit StateWidget(int flag, int index = 0,QWidget *parent = nullptr);
|
||||
|
||||
explicit StateWidget(int flag, QString t, QVariant v = 0, state s = state::inital, QWidget *parent = nullptr);
|
||||
explicit StateWidget(int flag, QString t, QVariant v = 0, state s = state::gray, int index = 0, QWidget *parent = nullptr);
|
||||
|
||||
~StateWidget();
|
||||
|
||||
|
||||
int id;
|
||||
|
||||
void setMax(double v)
|
||||
{
|
||||
max = v;
|
||||
}
|
||||
|
||||
void setMin(double v)
|
||||
{
|
||||
min = v;
|
||||
}
|
||||
|
||||
|
||||
|
||||
signals:
|
||||
|
||||
|
||||
@@ -54,6 +68,10 @@ private slots:
|
||||
|
||||
private:
|
||||
|
||||
|
||||
double max = 99999999999999999;
|
||||
double min = -99999999999999999;
|
||||
|
||||
QGridLayout *gridlayout;
|
||||
QLabel *title = nullptr;
|
||||
QLabel *label = nullptr;
|
||||
|
||||
@@ -38,6 +38,18 @@ void StatusUI::setValue(QLabel *w,QString s)
|
||||
w->setText(s);
|
||||
}
|
||||
|
||||
void StatusUI::install(int flag, QString t,QVariant v,StateWidget::state s,int index)
|
||||
{
|
||||
StateWidget *w = new StateWidget(flag,t,v,s,index);
|
||||
|
||||
|
||||
|
||||
StateList.insert(index,w);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void StatusUI::setMode(uint32_t pos,QVariant value1,QVariant value2)
|
||||
{
|
||||
switch (pos) {
|
||||
|
||||
@@ -28,8 +28,7 @@ public:
|
||||
~StatusUI();
|
||||
|
||||
|
||||
|
||||
QMap<int,QMap<int,QLabel *>> StateList;
|
||||
void install(int flag, QString t,QVariant v,StateWidget::state s,int index);
|
||||
|
||||
|
||||
public slots:
|
||||
@@ -53,6 +52,11 @@ private slots:
|
||||
|
||||
private:
|
||||
Ui::StatusUI *ui;
|
||||
|
||||
|
||||
QMap<int,StateWidget *> StateList;
|
||||
|
||||
|
||||
};
|
||||
|
||||
#endif // STATUSUI_H
|
||||
|
||||
Reference in New Issue
Block a user