31 lines
893 B
C++
31 lines
893 B
C++
#ifndef DATACARD_H
|
|
#define DATACARD_H
|
|
|
|
#include <QWidget>
|
|
#include <QVector>
|
|
|
|
class QLabel;
|
|
|
|
// ===================== 数据卡片 =====================
|
|
// 标题栏 + 若干“标签:值”行;支持指定字段红色闪烁告警
|
|
class DataCard : public QWidget
|
|
{
|
|
Q_OBJECT
|
|
public:
|
|
explicit DataCard(const QString& title, QWidget* parent = nullptr);
|
|
|
|
void setTitle(const QString& t);
|
|
int addField(const QString& label, const QString& value = "--", bool big = false);
|
|
void setField(int index, const QString& value);
|
|
void setAlarm(int index, bool on);
|
|
void setHighlight(bool on); // 主色描边突出
|
|
void indentRows(); // 字段行整体缩进到「中间偏左」(行首 : 行尾 = 2 : 3),只需调用一次
|
|
|
|
private:
|
|
QLabel* m_title = nullptr;
|
|
QVector<QLabel*> m_values;
|
|
QVector<QString> m_labels;
|
|
};
|
|
|
|
#endif // DATACARD_H
|