mirror of
https://gitee.com/js-yhsec/energy_storage.git
synced 2026-05-28 03:09:24 +08:00
修改设备显示信息的寄存器地址配置文件,修改服务端界面
This commit is contained in:
@@ -1,19 +1,66 @@
|
||||
#include "MyQUI.h"
|
||||
#include "MyQUI.h"
|
||||
|
||||
static const std::string QSS_GROUP =
|
||||
"QGroupBox { border: 1px solid gray; margin-top: 8px; border-radius: 5px;}"
|
||||
"QGroupBox::title { subcontrol-origin: margin; subcontrol-position: top left; left:10px; margin-left: 0px; padding:0 1px; }";
|
||||
|
||||
static const std::string QSS_BTN =
|
||||
"QPushButton {background:rgba(80, 80, 80,80);border-radius:5px;border:1px solid gray;color:white;font:bold 13px;}";
|
||||
|
||||
static const std::string QSS_BTN_ACTIVE =
|
||||
"QPushButton {background:rgba(80, 80, 80,80);border-radius:5px;border:1px solid green;color:green;font:bold 15px;}";
|
||||
|
||||
static const std::string QSS_BTN_MENU =
|
||||
"QPushButton {background:rgba(50,128,218,200);color:white;border-radius:5px;border:2px solid rgb(10,120,215);font:bold 18px;}"
|
||||
"QPushButton {background:rgba(19, 35, 71,200);color:white;border-radius:5px;border:2px solid rgb(10,120,215);font:bold 18px;}"
|
||||
"QPushButton:hover {background-color:rgb(32,164,128);}"
|
||||
"QPushButton:pressed {border-width:3px 0 0 3px;background-color:rgb(1,32,54);border-style:inset;}"
|
||||
"QPushButton:pressed {border-width:3px 0 0 3px;border-style:inset;}"
|
||||
"QPushButton:disabled {color:rgb(150,150,150);}";
|
||||
|
||||
static const std::string QSS_BTN_MENU_ACTIVE =
|
||||
"QPushButton {background:rgba(32,164,128, 200);color:white;border-radius:5px;border:2px solid rgb(10,120,215);font:bold 18px;}"
|
||||
"QPushButton:hover {background-color:rgb(32,164,128);}"
|
||||
"QPushButton:pressed {border-width:3px 0 0 3px;border-style:inset;}"
|
||||
"QPushButton:disabled {color:rgb(150,150,150);}";
|
||||
|
||||
static const std::string QSS_LINE =
|
||||
"QLineEdit { background-color: rgb(14, 49, 66); color: #ffffff; border: 1px solid gray; border-radius: 5px; font: bold 13px; }";
|
||||
|
||||
static const std::string QSS_TABLE = // 表格整体样式
|
||||
"QTableWidget {"
|
||||
" background-color: transparent;" // 背景色
|
||||
" gridline-color: #C0C0C0;" // 网格线颜色
|
||||
" border: 1px solid gray;" // 边框
|
||||
" color: white;" // 文字颜色
|
||||
"}"
|
||||
// 表头样式
|
||||
"QHeaderView { background-color: rgba(150,150,150,50); }"
|
||||
"QHeaderView::section {"
|
||||
" background-color: rgba(120,120,120,0);" // 表头背景
|
||||
" padding: 4px;" // 内边距
|
||||
" border: 1px solid #505050;" // 边框
|
||||
" min-height: 25px;" // 最小高度
|
||||
"}"
|
||||
// 单元格样式
|
||||
"QTableWidget::item {"
|
||||
" padding-left: 5px;"
|
||||
" border-bottom: 1px solid gray;" // 底部边框
|
||||
"}"
|
||||
// 选中状态
|
||||
"QTableWidget::item:selected {"
|
||||
" background-color: rgba(184, 214, 255, 50);" // 选中背景色
|
||||
" color: rgb(220,220,220);" // 选中文字颜色
|
||||
"}";
|
||||
|
||||
MyWidget::MyWidget(QWidget* parent) : QWidget(parent)
|
||||
{
|
||||
// 可以在这里设置样式表,也可以在其他地方设置
|
||||
setObjectName("MyWidget");
|
||||
setStyleSheet("#MyWidget {background-color:rgba(120,120,120,80); border-radius:5px;}");
|
||||
// 确保自动填充背景
|
||||
setAutoFillBackground(true);
|
||||
}
|
||||
|
||||
|
||||
std::shared_ptr<QGroupBox> MyQUI::GroupBox(QWidget* parent, int x, int y, int w, int h, std::string title)
|
||||
{
|
||||
auto groupBox = std::make_shared<QGroupBox>(title.c_str(), parent);
|
||||
@@ -22,14 +69,33 @@ std::shared_ptr<QGroupBox> MyQUI::GroupBox(QWidget* parent, int x, int y, int w,
|
||||
return groupBox;
|
||||
}
|
||||
|
||||
void MyQUI::PairLine(QWidget* parent, int x, int y, string k, string v)
|
||||
MyPairLabelLine MyQUI::PairLine(QWidget* parent, int x, int y, string k, string v, bool readonly/* = true*/)
|
||||
{
|
||||
auto key = new QLabel(parent);
|
||||
shared_ptr<QLabel> key = make_shared<QLabel>(parent);
|
||||
key->setText(k.c_str());
|
||||
key->setGeometry(x, y, 80, 26);
|
||||
auto value = new QLineEdit(parent);
|
||||
shared_ptr<QLineEdit> value = make_shared<QLineEdit>(parent);
|
||||
value->setText(v.c_str());
|
||||
value->setGeometry(x+80, y, 260, 26);
|
||||
value->setStyleSheet(QSS_LINE.c_str());
|
||||
value->setReadOnly(true);
|
||||
value->setReadOnly(readonly);
|
||||
return {key, value};
|
||||
}
|
||||
|
||||
void MyQUI::setTableCell(std::shared_ptr<QTableWidget> table, int row, int col, std::string text, std::string style /*= ""*/)
|
||||
{
|
||||
if (row >= table->rowCount())
|
||||
{
|
||||
table->insertRow(row);
|
||||
}
|
||||
auto item = table->item(row, col);
|
||||
if (!item)
|
||||
{
|
||||
item = new QTableWidgetItem();
|
||||
table->setItem(row, col, item);
|
||||
}
|
||||
item->setText(text.c_str());
|
||||
if (style == "OK") { item->setForeground(QBrush(Qt::green)); }
|
||||
else if (style == "ERR") { item->setForeground(QBrush(Qt::red)); }
|
||||
else if (style == "WARN") { item->setForeground(QBrush(Qt::cyan)); }
|
||||
}
|
||||
Reference in New Issue
Block a user