Переглянути джерело

all code version1 two set and tree done

flower 9 місяців тому
коміт
56f1062204

+ 20 - 0
code/login/login_switch.cpp

@@ -0,0 +1,20 @@
+#include "login_switch.h"
+#include "ui_login_switch.h"
+
+login_switch::login_switch(QWidget *parent) :
+    QWidget(parent),
+    ui(new Ui::login_switch)
+{
+    ui->setupUi(this);
+}
+
+login_switch::~login_switch()
+{
+    delete ui;
+}
+
+void login_switch::on_pushButton_clicked()
+{
+    page_main.show();
+}
+

+ 27 - 0
code/login/login_switch.h

@@ -0,0 +1,27 @@
+#ifndef LOGIN_SWITCH_H
+#define LOGIN_SWITCH_H
+
+#include <QWidget>
+#include "mainwindow.h"
+
+namespace Ui {
+class login_switch;
+}
+
+class login_switch : public QWidget
+{
+    Q_OBJECT
+
+public:
+    explicit login_switch(QWidget *parent = nullptr);
+    ~login_switch();
+
+private slots:
+    void on_pushButton_clicked();
+
+private:
+    Ui::login_switch *ui;
+    MainWindow page_main;
+};
+
+#endif // LOGIN_SWITCH_H

+ 212 - 0
code/login/login_switch.ui

@@ -0,0 +1,212 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>login_switch</class>
+ <widget class="QWidget" name="login_switch">
+  <property name="geometry">
+   <rect>
+    <x>0</x>
+    <y>0</y>
+    <width>792</width>
+    <height>522</height>
+   </rect>
+  </property>
+  <property name="windowTitle">
+   <string>台架选择</string>
+  </property>
+  <property name="windowIcon">
+   <iconset resource="../../icon/icon.qrc">
+    <normaloff>:/switch-on.svg</normaloff>:/switch-on.svg</iconset>
+  </property>
+  <layout class="QVBoxLayout" name="verticalLayout" stretch="2,8">
+   <item>
+    <widget class="QGroupBox" name="groupBox">
+     <property name="title">
+      <string/>
+     </property>
+     <layout class="QHBoxLayout" name="horizontalLayout_5">
+      <item>
+       <widget class="QLabel" name="page_label">
+        <property name="font">
+         <font>
+          <pointsize>26</pointsize>
+         </font>
+        </property>
+        <property name="layoutDirection">
+         <enum>Qt::LeftToRight</enum>
+        </property>
+        <property name="text">
+         <string>台架选择</string>
+        </property>
+        <property name="alignment">
+         <set>Qt::AlignCenter</set>
+        </property>
+       </widget>
+      </item>
+     </layout>
+    </widget>
+   </item>
+   <item>
+    <widget class="QGroupBox" name="groupBox_2">
+     <property name="layoutDirection">
+      <enum>Qt::LeftToRight</enum>
+     </property>
+     <property name="title">
+      <string/>
+     </property>
+     <property name="alignment">
+      <set>Qt::AlignCenter</set>
+     </property>
+     <layout class="QHBoxLayout" name="horizontalLayout">
+      <item>
+       <spacer name="horizontalSpacer">
+        <property name="orientation">
+         <enum>Qt::Horizontal</enum>
+        </property>
+        <property name="sizeHint" stdset="0">
+         <size>
+          <width>197</width>
+          <height>20</height>
+         </size>
+        </property>
+       </spacer>
+      </item>
+      <item>
+       <widget class="QGroupBox" name="groupBox_3">
+        <property name="title">
+         <string/>
+        </property>
+        <layout class="QVBoxLayout" name="verticalLayout_2">
+         <item>
+          <spacer name="verticalSpacer_2">
+           <property name="orientation">
+            <enum>Qt::Vertical</enum>
+           </property>
+           <property name="sizeHint" stdset="0">
+            <size>
+             <width>20</width>
+             <height>43</height>
+            </size>
+           </property>
+          </spacer>
+         </item>
+         <item>
+          <widget class="QPushButton" name="pushButton">
+           <property name="minimumSize">
+            <size>
+             <width>300</width>
+             <height>100</height>
+            </size>
+           </property>
+           <property name="maximumSize">
+            <size>
+             <width>300</width>
+             <height>100</height>
+            </size>
+           </property>
+           <property name="font">
+            <font>
+             <pointsize>15</pointsize>
+            </font>
+           </property>
+           <property name="text">
+            <string>仿真台架</string>
+           </property>
+           <property name="icon">
+            <iconset resource="../../icon/icon.qrc">
+             <normaloff>:/sine-wave.svg</normaloff>:/sine-wave.svg</iconset>
+           </property>
+           <property name="iconSize">
+            <size>
+             <width>30</width>
+             <height>30</height>
+            </size>
+           </property>
+          </widget>
+         </item>
+         <item>
+          <spacer name="verticalSpacer">
+           <property name="orientation">
+            <enum>Qt::Vertical</enum>
+           </property>
+           <property name="sizeHint" stdset="0">
+            <size>
+             <width>20</width>
+             <height>44</height>
+            </size>
+           </property>
+          </spacer>
+         </item>
+         <item>
+          <widget class="QPushButton" name="pushButton_2">
+           <property name="minimumSize">
+            <size>
+             <width>300</width>
+             <height>100</height>
+            </size>
+           </property>
+           <property name="maximumSize">
+            <size>
+             <width>300</width>
+             <height>100</height>
+            </size>
+           </property>
+           <property name="font">
+            <font>
+             <pointsize>15</pointsize>
+            </font>
+           </property>
+           <property name="text">
+            <string>试验台架</string>
+           </property>
+           <property name="icon">
+            <iconset resource="../../icon/icon.qrc">
+             <normaloff>:/airplay.svg</normaloff>:/airplay.svg</iconset>
+           </property>
+           <property name="iconSize">
+            <size>
+             <width>30</width>
+             <height>30</height>
+            </size>
+           </property>
+          </widget>
+         </item>
+         <item>
+          <spacer name="verticalSpacer_3">
+           <property name="orientation">
+            <enum>Qt::Vertical</enum>
+           </property>
+           <property name="sizeHint" stdset="0">
+            <size>
+             <width>18</width>
+             <height>14</height>
+            </size>
+           </property>
+          </spacer>
+         </item>
+        </layout>
+       </widget>
+      </item>
+      <item>
+       <spacer name="horizontalSpacer_2">
+        <property name="orientation">
+         <enum>Qt::Horizontal</enum>
+        </property>
+        <property name="sizeHint" stdset="0">
+         <size>
+          <width>197</width>
+          <height>20</height>
+         </size>
+        </property>
+       </spacer>
+      </item>
+     </layout>
+    </widget>
+   </item>
+  </layout>
+ </widget>
+ <resources>
+  <include location="../../icon/icon.qrc"/>
+  <include location="../../icon/icon.qrc"/>
+ </resources>
+ <connections/>
+</ui>

+ 37 - 0
code/set/set.cpp

@@ -0,0 +1,37 @@
+#include "set.h"
+#include "ui_set.h"
+#include <QTreeView>
+#include <QStandardItemModel>
+
+
+set::set(QWidget *parent) :
+    QMainWindow(parent),
+    ui(new Ui::set),
+    treeModel(nullptr)
+
+{
+    ui->setupUi(this);
+
+    // 将模型设置为 QTreeView 的模型
+    // 将模型设置为 QTreeView 的模型
+    QStandardItemModel* model = treeModel->tree_set();
+    ui->tree_set->setModel(model);
+    ui->tree_set->expandAll();
+
+
+    // 将 QTreeView 的 clicked 信号连接到 handleTreeItemClicked 槽函数
+    connect(ui->tree_set, &QTreeView::clicked, this, &set::handleTreeItemClicked);
+}
+
+void set::handleTreeItemClicked(const QModelIndex &index) {
+    // 转发信号
+    emit treeItemClicked(index);
+}
+void set::setTreeModel(tree_model_set* model)
+{
+    treeModel = model; // 设置 tree_model_set 实例
+}
+set::~set()
+{
+    delete ui;
+}

+ 34 - 0
code/set/set.h

@@ -0,0 +1,34 @@
+// set.h
+#ifndef SET_H
+#define SET_H
+
+#include <QMainWindow>
+#include <QModelIndex>
+#include "code/tree/tree_model_set.h"
+
+namespace Ui {
+class set;
+}
+
+class set : public QMainWindow
+{
+    Q_OBJECT
+
+public:
+    explicit set(QWidget *parent = nullptr);
+    void setTreeModel(tree_model_set* model); // 接受 tree_model_set 实例
+
+    ~set();
+
+signals:
+    void treeItemClicked(const QModelIndex &index);
+
+private slots:
+    void handleTreeItemClicked(const QModelIndex &index);
+
+private:
+    Ui::set *ui;
+    tree_model_set* treeModel; // 保存 tree_model_set 实例的指针
+};
+
+#endif // SET_H

+ 355 - 0
code/set/set.ui

@@ -0,0 +1,355 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>set</class>
+ <widget class="QMainWindow" name="set">
+  <property name="geometry">
+   <rect>
+    <x>0</x>
+    <y>0</y>
+    <width>810</width>
+    <height>648</height>
+   </rect>
+  </property>
+  <property name="windowTitle">
+   <string>MainWindow</string>
+  </property>
+  <widget class="QWidget" name="centralwidget">
+   <layout class="QVBoxLayout" name="verticalLayout_4">
+    <item>
+     <layout class="QVBoxLayout" name="verticalLayout_2" stretch="3,10">
+      <item>
+       <widget class="QGroupBox" name="groupBox">
+        <property name="title">
+         <string/>
+        </property>
+        <layout class="QHBoxLayout" name="horizontalLayout_4">
+         <item>
+          <widget class="QLabel" name="page_label">
+           <property name="font">
+            <font>
+             <pointsize>26</pointsize>
+            </font>
+           </property>
+           <property name="layoutDirection">
+            <enum>Qt::LeftToRight</enum>
+           </property>
+           <property name="text">
+            <string>仿真设置</string>
+           </property>
+           <property name="alignment">
+            <set>Qt::AlignCenter</set>
+           </property>
+          </widget>
+         </item>
+        </layout>
+       </widget>
+      </item>
+      <item>
+       <layout class="QHBoxLayout" name="horizontalLayout_2">
+        <item>
+         <widget class="QTreeView" name="tree_set">
+          <property name="maximumSize">
+           <size>
+            <width>150</width>
+            <height>16777215</height>
+           </size>
+          </property>
+         </widget>
+        </item>
+        <item>
+         <layout class="QVBoxLayout" name="verticalLayout" stretch="3,10">
+          <item>
+           <widget class="QGroupBox" name="groupBox_2">
+            <property name="title">
+             <string>GroupBox</string>
+            </property>
+            <layout class="QHBoxLayout" name="horizontalLayout">
+             <item>
+              <spacer name="horizontalSpacer">
+               <property name="orientation">
+                <enum>Qt::Horizontal</enum>
+               </property>
+               <property name="sizeType">
+                <enum>QSizePolicy::Minimum</enum>
+               </property>
+               <property name="sizeHint" stdset="0">
+                <size>
+                 <width>20</width>
+                 <height>20</height>
+                </size>
+               </property>
+              </spacer>
+             </item>
+             <item>
+              <widget class="QLabel" name="label">
+               <property name="text">
+                <string>工况选择</string>
+               </property>
+              </widget>
+             </item>
+             <item>
+              <spacer name="horizontalSpacer_2">
+               <property name="orientation">
+                <enum>Qt::Horizontal</enum>
+               </property>
+               <property name="sizeType">
+                <enum>QSizePolicy::Minimum</enum>
+               </property>
+               <property name="sizeHint" stdset="0">
+                <size>
+                 <width>20</width>
+                 <height>20</height>
+                </size>
+               </property>
+              </spacer>
+             </item>
+             <item>
+              <widget class="QComboBox" name="situation_switch">
+               <property name="minimumSize">
+                <size>
+                 <width>150</width>
+                 <height>0</height>
+                </size>
+               </property>
+               <item>
+                <property name="text">
+                 <string>稳态工况</string>
+                </property>
+               </item>
+               <item>
+                <property name="text">
+                 <string>切换工况</string>
+                </property>
+               </item>
+              </widget>
+             </item>
+             <item>
+              <spacer name="horizontalSpacer_3">
+               <property name="orientation">
+                <enum>Qt::Horizontal</enum>
+               </property>
+               <property name="sizeHint" stdset="0">
+                <size>
+                 <width>310</width>
+                 <height>20</height>
+                </size>
+               </property>
+              </spacer>
+             </item>
+            </layout>
+           </widget>
+          </item>
+          <item>
+           <widget class="QStackedWidget" name="stackedWidget">
+            <property name="currentIndex">
+             <number>0</number>
+            </property>
+            <widget class="QWidget" name="page">
+             <layout class="QVBoxLayout" name="verticalLayout_5">
+              <item>
+               <widget class="QGroupBox" name="groupBox_3">
+                <property name="title">
+                 <string>工况设置</string>
+                </property>
+                <layout class="QHBoxLayout" name="horizontalLayout_7" stretch="1,1">
+                 <item>
+                  <widget class="QGroupBox" name="groupBox_7">
+                   <property name="title">
+                    <string/>
+                   </property>
+                   <layout class="QHBoxLayout" name="horizontalLayout_5">
+                    <item>
+                     <widget class="QLabel" name="label_2">
+                      <property name="text">
+                       <string>稳态工况</string>
+                      </property>
+                     </widget>
+                    </item>
+                    <item>
+                     <widget class="QComboBox" name="situation_wt"/>
+                    </item>
+                   </layout>
+                  </widget>
+                 </item>
+                 <item>
+                  <widget class="QGroupBox" name="groupBox_8">
+                   <property name="title">
+                    <string/>
+                   </property>
+                   <layout class="QHBoxLayout" name="horizontalLayout_8">
+                    <item>
+                     <widget class="QLabel" name="label_6">
+                      <property name="text">
+                       <string>仿真时间</string>
+                      </property>
+                     </widget>
+                    </item>
+                    <item>
+                     <widget class="QTextEdit" name="textEdit">
+                      <property name="maximumSize">
+                       <size>
+                        <width>100</width>
+                        <height>30</height>
+                       </size>
+                      </property>
+                     </widget>
+                    </item>
+                   </layout>
+                  </widget>
+                 </item>
+                </layout>
+               </widget>
+              </item>
+              <item>
+               <widget class="QGroupBox" name="groupBox_4">
+                <property name="title">
+                 <string>干扰设置</string>
+                </property>
+                <layout class="QVBoxLayout" name="verticalLayout_3">
+                 <item>
+                  <widget class="QCheckBox" name="checkBox">
+                   <property name="text">
+                    <string>干扰开启</string>
+                   </property>
+                  </widget>
+                 </item>
+                 <item>
+                  <widget class="QGroupBox" name="groupBox_5">
+                   <property name="title">
+                    <string/>
+                   </property>
+                   <layout class="QHBoxLayout" name="horizontalLayout_3">
+                    <item>
+                     <widget class="QLabel" name="label_4">
+                      <property name="text">
+                       <string>开始时间</string>
+                      </property>
+                     </widget>
+                    </item>
+                    <item>
+                     <widget class="QPlainTextEdit" name="plainTextEdit">
+                      <property name="maximumSize">
+                       <size>
+                        <width>100</width>
+                        <height>30</height>
+                       </size>
+                      </property>
+                     </widget>
+                    </item>
+                    <item>
+                     <spacer name="horizontalSpacer_4">
+                      <property name="orientation">
+                       <enum>Qt::Horizontal</enum>
+                      </property>
+                      <property name="sizeHint" stdset="0">
+                       <size>
+                        <width>370</width>
+                        <height>20</height>
+                       </size>
+                      </property>
+                     </spacer>
+                    </item>
+                   </layout>
+                  </widget>
+                 </item>
+                 <item>
+                  <widget class="QGroupBox" name="groupBox_6">
+                   <property name="title">
+                    <string/>
+                   </property>
+                   <layout class="QHBoxLayout" name="horizontalLayout_6">
+                    <item>
+                     <widget class="QLabel" name="label_5">
+                      <property name="text">
+                       <string>结束时间</string>
+                      </property>
+                     </widget>
+                    </item>
+                    <item>
+                     <widget class="QPlainTextEdit" name="plainTextEdit_2">
+                      <property name="maximumSize">
+                       <size>
+                        <width>100</width>
+                        <height>30</height>
+                       </size>
+                      </property>
+                     </widget>
+                    </item>
+                    <item>
+                     <spacer name="horizontalSpacer_5">
+                      <property name="orientation">
+                       <enum>Qt::Horizontal</enum>
+                      </property>
+                      <property name="sizeHint" stdset="0">
+                       <size>
+                        <width>370</width>
+                        <height>20</height>
+                       </size>
+                      </property>
+                     </spacer>
+                    </item>
+                   </layout>
+                  </widget>
+                 </item>
+                </layout>
+               </widget>
+              </item>
+              <item>
+               <widget class="QPushButton" name="pushButton">
+                <property name="text">
+                 <string>确认设置</string>
+                </property>
+               </widget>
+              </item>
+             </layout>
+            </widget>
+            <widget class="QWidget" name="page_2">
+             <widget class="QLabel" name="label_3">
+              <property name="geometry">
+               <rect>
+                <x>40</x>
+                <y>30</y>
+                <width>67</width>
+                <height>20</height>
+               </rect>
+              </property>
+              <property name="text">
+               <string>TextLabel</string>
+              </property>
+             </widget>
+             <widget class="QComboBox" name="comboBox_3">
+              <property name="geometry">
+               <rect>
+                <x>180</x>
+                <y>20</y>
+                <width>89</width>
+                <height>28</height>
+               </rect>
+              </property>
+             </widget>
+            </widget>
+           </widget>
+          </item>
+         </layout>
+        </item>
+       </layout>
+      </item>
+     </layout>
+    </item>
+   </layout>
+  </widget>
+  <widget class="QMenuBar" name="menubar">
+   <property name="geometry">
+    <rect>
+     <x>0</x>
+     <y>0</y>
+     <width>810</width>
+     <height>25</height>
+    </rect>
+   </property>
+  </widget>
+  <widget class="QStatusBar" name="statusbar"/>
+ </widget>
+ <resources/>
+ <connections/>
+</ui>

+ 114 - 0
code/tcp/tcp.cpp

@@ -0,0 +1,114 @@
+#include "tcp.h"
+#include "ui_tcp.h"
+
+tcp::tcp(QWidget *parent) :
+    QMainWindow(parent),
+    ui(new Ui::tcp)
+{
+    ui->setupUi(this);
+    ui->port->setText("8899");
+    setWindowTitle("tcp设置");
+    connectNum=0;
+    ui->disconnect->setDisabled(true);
+    ui->sendMsg->setEnabled(true);
+    // 创建监听的服务器对象
+    ms = new QTcpServer(this);
+    connect(ms, &QTcpServer::newConnection, this, [=]() {
+        QTcpSocket* clientSocket = ms->nextPendingConnection();
+        mstatus->setPixmap(QPixmap(":/accessibility.svg").scaled(20, 20));
+
+        ui->disconnect->setEnabled(true);
+
+        // 将客户端连接添加到连接管理中
+        connectedClients[clientSocket] = "";
+
+
+        // 增加处理连接的信号和槽
+        connectClient(clientSocket);
+
+    });
+
+    // 状态栏处理动作
+    mstatus = new QLabel;
+    // mstatus->setPixmap(QPixmap(qrc:/accessibility.svg).scaled(20,20));
+    ui->statusbar->addWidget(new QLabel("是否有用户连接:"));
+    ui->statusbar->addWidget(mstatus);
+}
+
+tcp::~tcp()
+{
+    delete ui;
+}
+
+void tcp::on_setListen_clicked()
+{
+    unsigned short port = ui->port->text().toUShort();  // 获取端口号
+    ms->listen(QHostAddress::Any, port);  // 监听所有地址上的指定端口
+    ui->setListen->setDisabled(true);  // 禁用监听按钮
+
+}
+
+void tcp::connectClient(QTcpSocket *clientSocket)
+{
+    connectNum++;
+    connect(clientSocket, &QTcpSocket::readyRead, this, [=]() {
+
+        ui->usermsg->append("matlab连接");
+        QByteArray data = clientSocket->readAll();
+        if (data.isEmpty())
+            return;
+
+        char dataType = data.at(0);  // 读取前缀
+        data.remove(0, 1);  // 移除前缀
+
+        if (dataType == 'T') {
+            // 处理文本数据
+            QString message = QString::fromUtf8(data);
+            ui->record->append("收到文本: " + message);
+        } else if (dataType == 'D')  {
+            // 处理数字数据
+            QVector<double> receivedData;
+            int dataSize = data.size() / sizeof(double);
+
+            for (int i = 0; i < dataSize; ++i) {
+                double value;
+                memcpy(&value, data.data() + i * sizeof(double), sizeof(double));
+                receivedData.append(value);
+            }
+            QString numbers;
+            for (double num : receivedData)
+            {
+                numbers += QString::number(num, 'f', 6) + " ";
+            }
+            ui->record->append("收到数据: " + numbers.trimmed());
+            QString dataSizeStr = QString::number(dataSize);
+            ui->msg->append("收到数据长度: " + dataSizeStr);
+            data.clear();  // 清空 data
+        }
+    });
+
+    connect(clientSocket, &QTcpSocket::disconnected, this, [=]() {
+        clientSocket->close();
+        connectedClients.remove(clientSocket);
+        connectNum = 0;
+
+        // 更新状态栏
+        if (connectNum == 0) {
+            mstatus->setPixmap(QPixmap(":/f.PNG").scaled(20, 20));
+            ui->usermsg->append("matlab断开连接");
+        }
+    });
+}
+
+void tcp::on_sendMsg_clicked()
+{
+    QString msg = ui->msg->toPlainText();  // 获取要发送的消息
+    QString serverMsg = "[Server] " + msg;  // 添加服务器标识
+    for (auto clientSocket : connectedClients.keys()) {
+        if (clientSocket->state() == QAbstractSocket::ConnectedState) {
+            clientSocket->write(serverMsg.toUtf8());  // 发送消息
+        }
+    }
+    ui->record->append("服务端广播消息: " + msg);  // 在记录中显示发送的消息
+}
+

+ 41 - 0
code/tcp/tcp.h

@@ -0,0 +1,41 @@
+#ifndef TCP_H
+#define TCP_H
+
+#include <QMainWindow>
+#include <QTcpServer>
+#include <QTcpSocket>
+#include <QLabel>
+#include <QFile>
+
+namespace Ui {
+class tcp;
+}
+
+class tcp : public QMainWindow
+{
+    Q_OBJECT
+
+public:
+    explicit tcp(QWidget *parent = nullptr);
+    ~tcp();
+
+private slots:
+    void on_setListen_clicked();
+    void connectClient(QTcpSocket *clientSocket);
+
+    void on_sendMsg_clicked();
+
+private:
+    Ui::tcp *ui;
+    QTcpServer* ms;
+    QTcpSocket* mtcp;
+    QLabel* mstatus;
+    // QFile *file;
+    QMap<QTcpSocket*, QString> connectedClients;
+    QString sendname;
+
+    int connectNum;
+    int clientIdentifierCounter = 1;
+};
+
+#endif // TCP_H

+ 222 - 0
code/tcp/tcp.ui

@@ -0,0 +1,222 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>tcp</class>
+ <widget class="QMainWindow" name="tcp">
+  <property name="geometry">
+   <rect>
+    <x>0</x>
+    <y>0</y>
+    <width>363</width>
+    <height>626</height>
+   </rect>
+  </property>
+  <property name="windowTitle">
+   <string>MainWindow</string>
+  </property>
+  <property name="windowIcon">
+   <iconset resource="../../icon/icon.qrc">
+    <normaloff>:/ip-address-tag.svg</normaloff>:/ip-address-tag.svg</iconset>
+  </property>
+  <widget class="QWidget" name="centralwidget">
+   <widget class="QGroupBox" name="groupBox_3">
+    <property name="geometry">
+     <rect>
+      <x>0</x>
+      <y>390</y>
+      <width>339</width>
+      <height>178</height>
+     </rect>
+    </property>
+    <property name="title">
+     <string>已登录用户信息:</string>
+    </property>
+    <property name="flat">
+     <bool>false</bool>
+    </property>
+    <property name="checkable">
+     <bool>false</bool>
+    </property>
+    <widget class="QTextEdit" name="usermsg">
+     <property name="geometry">
+      <rect>
+       <x>14</x>
+       <y>36</y>
+       <width>321</width>
+       <height>111</height>
+      </rect>
+     </property>
+     <property name="styleSheet">
+      <string notr="true"/>
+     </property>
+    </widget>
+   </widget>
+   <widget class="QGroupBox" name="groupBox">
+    <property name="geometry">
+     <rect>
+      <x>0</x>
+      <y>70</y>
+      <width>339</width>
+      <height>179</height>
+     </rect>
+    </property>
+    <property name="mouseTracking">
+     <bool>false</bool>
+    </property>
+    <property name="title">
+     <string>接受信息:</string>
+    </property>
+    <widget class="QTextEdit" name="record">
+     <property name="geometry">
+      <rect>
+       <x>14</x>
+       <y>36</y>
+       <width>321</width>
+       <height>111</height>
+      </rect>
+     </property>
+     <property name="styleSheet">
+      <string notr="true"/>
+     </property>
+    </widget>
+   </widget>
+   <widget class="QGroupBox" name="groupBox_2">
+    <property name="geometry">
+     <rect>
+      <x>0</x>
+      <y>256</y>
+      <width>339</width>
+      <height>112</height>
+     </rect>
+    </property>
+    <property name="maximumSize">
+     <size>
+      <width>16777215</width>
+      <height>112</height>
+     </size>
+    </property>
+    <property name="styleSheet">
+     <string notr="true">font: 700 9pt &quot;Microsoft YaHei UI&quot;;</string>
+    </property>
+    <property name="title">
+     <string>输入信息:</string>
+    </property>
+    <widget class="QTextEdit" name="msg">
+     <property name="geometry">
+      <rect>
+       <x>14</x>
+       <y>26</y>
+       <width>321</width>
+       <height>81</height>
+      </rect>
+     </property>
+     <property name="styleSheet">
+      <string notr="true"/>
+     </property>
+    </widget>
+   </widget>
+   <widget class="QPushButton" name="sendMsg">
+    <property name="geometry">
+     <rect>
+      <x>240</x>
+      <y>380</y>
+      <width>80</width>
+      <height>29</height>
+     </rect>
+    </property>
+    <property name="styleSheet">
+     <string notr="true"/>
+    </property>
+    <property name="text">
+     <string>发送信息</string>
+    </property>
+   </widget>
+   <widget class="QWidget" name="widget" native="true">
+    <property name="geometry">
+     <rect>
+      <x>20</x>
+      <y>10</y>
+      <width>306</width>
+      <height>51</height>
+     </rect>
+    </property>
+    <widget class="QLabel" name="label">
+     <property name="geometry">
+      <rect>
+       <x>11</x>
+       <y>11</y>
+       <width>50</width>
+       <height>20</height>
+      </rect>
+     </property>
+     <property name="text">
+      <string>端口: </string>
+     </property>
+    </widget>
+    <widget class="QLineEdit" name="port">
+     <property name="enabled">
+      <bool>false</bool>
+     </property>
+     <property name="geometry">
+      <rect>
+       <x>68</x>
+       <y>12</y>
+       <width>53</width>
+       <height>27</height>
+      </rect>
+     </property>
+     <property name="styleSheet">
+      <string notr="true"/>
+     </property>
+    </widget>
+    <widget class="QPushButton" name="setListen">
+     <property name="geometry">
+      <rect>
+       <x>128</x>
+       <y>11</y>
+       <width>80</width>
+       <height>29</height>
+      </rect>
+     </property>
+     <property name="styleSheet">
+      <string notr="true"/>
+     </property>
+     <property name="text">
+      <string>启动连接</string>
+     </property>
+    </widget>
+    <widget class="QPushButton" name="disconnect">
+     <property name="geometry">
+      <rect>
+       <x>215</x>
+       <y>11</y>
+       <width>80</width>
+       <height>29</height>
+      </rect>
+     </property>
+     <property name="styleSheet">
+      <string notr="true"/>
+     </property>
+     <property name="text">
+      <string>关闭连接</string>
+     </property>
+    </widget>
+   </widget>
+  </widget>
+  <widget class="QMenuBar" name="menubar">
+   <property name="geometry">
+    <rect>
+     <x>0</x>
+     <y>0</y>
+     <width>363</width>
+     <height>25</height>
+    </rect>
+   </property>
+  </widget>
+  <widget class="QStatusBar" name="statusbar"/>
+ </widget>
+ <resources>
+  <include location="../../icon/icon.qrc"/>
+  <include location="../../icon/icon.qrc"/>
+ </resources>
+ <connections/>
+</ui>

+ 32 - 0
code/tree/tree_model_set.cpp

@@ -0,0 +1,32 @@
+#include "tree_model_set.h"
+
+tree_model_set::tree_model_set()
+{
+    // 构造函数实现,必要时进行初始化
+}
+
+
+QStandardItemModel* tree_model_set::tree_set()
+{
+    // 创建一个模型
+    QStandardItemModel *model = new QStandardItemModel();
+    model->setHorizontalHeaderLabels({"仿真台架"});
+    // 创建根节点
+    QStandardItem *rootItem = new QStandardItem("仿真设置");
+    rootItem->setFlags(rootItem->flags() & ~Qt::ItemIsEditable);
+    // 创建子节点
+    QStandardItem *childItem1 = new QStandardItem("TCP设置");
+    childItem1->setFlags(childItem1->flags() & ~Qt::ItemIsEditable);
+    childItem1->setData("page_tcp", Qt::UserRole);
+    QStandardItem *childItem2 = new QStandardItem("工况设置");
+    childItem2->setFlags(childItem2->flags() & ~Qt::ItemIsEditable);
+    childItem2->setData("page_set", Qt::UserRole);
+    // 将子节点添加到根节点
+    rootItem->appendRow(childItem1);
+    rootItem->appendRow(childItem2);
+    // 将根节点添加到模型
+    model->appendRow(rootItem);
+    // 将模型设置为 QTreeView 的模型
+    return model;
+
+}