diff --git a/include/queryListItem.h b/include/queryListItem.h new file mode 100644 index 0000000..3fea9ad --- /dev/null +++ b/include/queryListItem.h @@ -0,0 +1,36 @@ +// +// Created by ricardo on 2022/6/25. +// + +#ifndef AUTO_BUS_GUI_QUERY_LIST_ITEM_H +#define AUTO_BUS_GUI_QUERY_LIST_ITEM_H +#include "QWidget" +#include "QObject" +#include "QLabel" +#include "QHBoxLayout" + +class QueryListItem : public QWidget +{ + Q_OBJECT +public: + explicit QueryListItem(const int &type, const int &node_id); + + void SetColumnName(); + +private: + /** + * 请求的类型 + */ + QLabel type_text; + + /** + * 请求的目标站点 + */ + QLabel target_pos_text; + + /** + * 水平排列布局 + */ + QHBoxLayout *layout; +}; +#endif //AUTO_BUS_GUI_QUERY_LIST_ITEM_H diff --git a/src/queryListItem.cpp b/src/queryListItem.cpp new file mode 100644 index 0000000..b6885ac --- /dev/null +++ b/src/queryListItem.cpp @@ -0,0 +1,32 @@ +// +// Created by ricardo on 2022/6/25. +// + +#include "moc_queryListItem.cpp" + +QueryListItem::QueryListItem(const int &type, const int &node_id) : QWidget() +{ + QFont font("Microsoft YaHei", 10, 75); + layout = new QHBoxLayout(this); + + layout->addWidget(&type_text); + layout->addWidget(&target_pos_text); + layout->setContentsMargins(0, 0, 0, 0); + + this->setFixedHeight(20); + + // 设置文本 + type_text.setText(QString::number(type)); + target_pos_text.setText(QString::number(node_id)); + type_text.setFont(font); + target_pos_text.setFont(font); + + type_text.resize(30, 20); + target_pos_text.resize(30, 20); +} + +void QueryListItem::SetColumnName() +{ + type_text.setText(QString("请求类型")); + target_pos_text.setText(QString("目标站点")); +}