This commit is contained in:
2025-10-17 17:55:45 +08:00
parent ee6f767c42
commit cecda7ccd7
7 changed files with 42 additions and 31 deletions
@@ -9,7 +9,7 @@ public:
QFont font2 = QFont("微软雅黑", 10, QFont::Bold);
QFont font3 = QFont("微软雅黑", 6, QFont::Bold);
plcValueViewer(const QString& groupNameIN,
const std::vector<std::pair<QString, int>>& viewerNameAndAddress,
const std::vector<PlcValueViewerStruct>& viewerNameAndAddress,
QMap<int, std::vector<QLabel*>>& plcViwerLineedits)
:groupName(groupNameIN){
@@ -20,7 +20,7 @@ public:
layout->addWidget(groupNameLabel);
for (auto& data : viewerNameAndAddress) {
plcViwerLineedits[data.second].push_back(addViewer(data.first));
plcViwerLineedits[data.valueAddr].push_back(addViewer(data.valueName));
}
widget->setMaximumHeight(100);
}
@@ -91,13 +91,13 @@ public slots:
}
});
}
void addPlcValueViewer(const QString& groupName,std::vector<std::pair<QString, int>> viewerNameAndAddress) {
void addPlcValueViewer(const QString& groupName,std::vector<PlcValueViewerStruct> viewerNameAndAddress) {
auto widget = new plcValueViewer(groupName, viewerNameAndAddress, plcViwerLineedits);
plcValueViewerLayout->addWidget(widget->widget,Qt::AlignTop);
}
void refreshPlcValueViewer(int address, int value) {
void refreshPlcValueViewer(int address, QVariant value) {
for (auto& lineedit : plcViwerLineedits[address]) {
lineedit->setText(QString::number(value));
lineedit->setText(value.toString());
}
}
private: