From dbf8049b358d25a70dd46170504f75fb4530e4ee Mon Sep 17 00:00:00 2001
From: email <15737449156@163.com>
Date: Tue, 5 Aug 2025 18:23:24 +0800
Subject: [PATCH] =?UTF-8?q?=E5=88=9D=E5=A7=8B=E5=8C=96=E7=95=8C=E9=9D=A2?=
=?UTF-8?q?=E8=AE=BE=E7=BD=AE=EF=BC=8C=E6=8C=89=E9=92=AE=E5=AE=9E=E7=8E=B0?=
=?UTF-8?q?=E7=AE=80=E5=8D=95=E7=BB=98=E5=9B=BE=E5=8A=9F=E8=83=BD?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
IntegratedPlatform/IntegratedPlatform.pro | 35 ++
.../IntegratedPlatform.pro.user | 562 ++++++++++++++++++
IntegratedPlatform/hmiwidget.cpp | 0
IntegratedPlatform/hmiwidget.h | 4 +
IntegratedPlatform/main.cpp | 12 +
IntegratedPlatform/mainwindow.cpp | 71 +++
IntegratedPlatform/mainwindow.h | 30 +
IntegratedPlatform/mainwindow.ui | 312 ++++++++++
8 files changed, 1026 insertions(+)
create mode 100644 IntegratedPlatform/IntegratedPlatform.pro
create mode 100644 IntegratedPlatform/IntegratedPlatform.pro.user
create mode 100644 IntegratedPlatform/hmiwidget.cpp
create mode 100644 IntegratedPlatform/hmiwidget.h
create mode 100644 IntegratedPlatform/main.cpp
create mode 100644 IntegratedPlatform/mainwindow.cpp
create mode 100644 IntegratedPlatform/mainwindow.h
create mode 100644 IntegratedPlatform/mainwindow.ui
diff --git a/IntegratedPlatform/IntegratedPlatform.pro b/IntegratedPlatform/IntegratedPlatform.pro
new file mode 100644
index 0000000..218c7d5
--- /dev/null
+++ b/IntegratedPlatform/IntegratedPlatform.pro
@@ -0,0 +1,35 @@
+QT += core gui
+
+greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
+
+CONFIG += c++11
+
+# The following define makes your compiler emit warnings if you use
+# any Qt feature that has been marked deprecated (the exact warnings
+# depend on your compiler). Please consult the documentation of the
+# deprecated API in order to know how to port your code away from it.
+DEFINES += QT_DEPRECATED_WARNINGS
+
+# You can also make your code fail to compile if it uses deprecated APIs.
+# In order to do so, uncomment the following line.
+# You can also select to disable deprecated APIs only up to a certain version of Qt.
+#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0
+
+SOURCES += \
+ hmiwidget.cpp \
+ main.cpp \
+ mainwindow.cpp
+
+HEADERS += \
+ hmiwidget.h \
+ mainwindow.h
+
+FORMS += \
+ mainwindow.ui
+
+# Default rules for deployment.
+qnx: target.path = /tmp/$${TARGET}/bin
+else: unix:!android: target.path = /opt/$${TARGET}/bin
+!isEmpty(target.path): INSTALLS += target
+
+DISTFILES +=
diff --git a/IntegratedPlatform/IntegratedPlatform.pro.user b/IntegratedPlatform/IntegratedPlatform.pro.user
new file mode 100644
index 0000000..7696a43
--- /dev/null
+++ b/IntegratedPlatform/IntegratedPlatform.pro.user
@@ -0,0 +1,562 @@
+
+
+
+
+
+ EnvironmentId
+ {a9bf9b5a-270d-4be3-80ad-6036193da221}
+
+
+ ProjectExplorer.Project.ActiveTarget
+ 0
+
+
+ ProjectExplorer.Project.EditorSettings
+
+ true
+ false
+ true
+
+ Cpp
+
+ CppGlobal
+
+
+
+ QmlJS
+
+ QmlJSGlobal
+
+
+ 2
+ UTF-8
+ false
+ 4
+ false
+ 80
+ true
+ true
+ 1
+ true
+ false
+ 0
+ true
+ true
+ 0
+ 8
+ true
+ 1
+ true
+ true
+ true
+ false
+
+
+
+ ProjectExplorer.Project.PluginSettings
+
+
+ -fno-delayed-template-parsing
+
+ true
+
+
+
+ ProjectExplorer.Project.Target.0
+
+ Desktop Qt 5.14.2 MinGW 32-bit
+ Desktop Qt 5.14.2 MinGW 32-bit
+ qt.qt5.5142.win32_mingw73_kit
+ 0
+ 0
+ 0
+
+ C:/Users/admin/Desktop/build-IntegratedPlatform-Desktop_Qt_5_14_2_MinGW_32_bit-Debug
+
+
+ true
+ QtProjectManager.QMakeBuildStep
+ true
+
+ false
+ false
+ false
+
+
+ true
+ Qt4ProjectManager.MakeStep
+
+ false
+
+
+ false
+
+ 2
+ Build
+ Build
+ ProjectExplorer.BuildSteps.Build
+
+
+
+ true
+ Qt4ProjectManager.MakeStep
+
+ true
+ clean
+
+ false
+
+ 1
+ Clean
+ Clean
+ ProjectExplorer.BuildSteps.Clean
+
+ 2
+ false
+
+ Debug
+ Qt4ProjectManager.Qt4BuildConfiguration
+ 2
+
+
+ C:/Users/admin/Desktop/build-IntegratedPlatform-Desktop_Qt_5_14_2_MinGW_32_bit-Release
+
+
+ true
+ QtProjectManager.QMakeBuildStep
+ false
+
+ false
+ false
+ true
+
+
+ true
+ Qt4ProjectManager.MakeStep
+
+ false
+
+
+ false
+
+ 2
+ Build
+ Build
+ ProjectExplorer.BuildSteps.Build
+
+
+
+ true
+ Qt4ProjectManager.MakeStep
+
+ true
+ clean
+
+ false
+
+ 1
+ Clean
+ Clean
+ ProjectExplorer.BuildSteps.Clean
+
+ 2
+ false
+
+ Release
+ Qt4ProjectManager.Qt4BuildConfiguration
+ 0
+
+
+ C:/Users/admin/Desktop/build-IntegratedPlatform-Desktop_Qt_5_14_2_MinGW_32_bit-Profile
+
+
+ true
+ QtProjectManager.QMakeBuildStep
+ true
+
+ false
+ true
+ true
+
+
+ true
+ Qt4ProjectManager.MakeStep
+
+ false
+
+
+ false
+
+ 2
+ Build
+ Build
+ ProjectExplorer.BuildSteps.Build
+
+
+
+ true
+ Qt4ProjectManager.MakeStep
+
+ true
+ clean
+
+ false
+
+ 1
+ Clean
+ Clean
+ ProjectExplorer.BuildSteps.Clean
+
+ 2
+ false
+
+ Profile
+ Qt4ProjectManager.Qt4BuildConfiguration
+ 0
+
+ 3
+
+
+ 0
+ Deploy
+ Deploy
+ ProjectExplorer.BuildSteps.Deploy
+
+ 1
+ ProjectExplorer.DefaultDeployConfiguration
+
+ 1
+
+
+ dwarf
+
+ cpu-cycles
+
+
+ 250
+
+ -e
+ cpu-cycles
+ --call-graph
+ dwarf,4096
+ -F
+ 250
+
+ -F
+ true
+ 4096
+ false
+ false
+ 1000
+
+ true
+
+ false
+ false
+ false
+ false
+ true
+ 0.01
+ 10
+ true
+ kcachegrind
+ 1
+ 25
+
+ 1
+ true
+ false
+ true
+ valgrind
+
+ 0
+ 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+ 10
+ 11
+ 12
+ 13
+ 14
+
+ 2
+
+
+ ProjectExplorer.CustomExecutableRunConfiguration
+
+
+ false
+
+ false
+ true
+ false
+ false
+ true
+
+
+
+ 1
+
+
+
+ ProjectExplorer.Project.Target.1
+
+ Desktop Qt 5.14.2 MinGW 64-bit
+ Desktop Qt 5.14.2 MinGW 64-bit
+ qt.qt5.5142.win64_mingw73_kit
+ 0
+ 0
+ 0
+
+ C:/Users/admin/Desktop/build-IntegratedPlatform-Desktop_Qt_5_14_2_MinGW_64_bit-Debug
+
+
+ true
+ QtProjectManager.QMakeBuildStep
+ true
+
+ false
+ false
+ false
+
+
+ true
+ Qt4ProjectManager.MakeStep
+
+ false
+
+
+ false
+
+ 2
+ Build
+ Build
+ ProjectExplorer.BuildSteps.Build
+
+
+
+ true
+ Qt4ProjectManager.MakeStep
+
+ true
+ clean
+
+ false
+
+ 1
+ Clean
+ Clean
+ ProjectExplorer.BuildSteps.Clean
+
+ 2
+ false
+
+ Debug
+ Qt4ProjectManager.Qt4BuildConfiguration
+ 2
+
+
+ C:/Users/admin/Desktop/build-IntegratedPlatform-Desktop_Qt_5_14_2_MinGW_64_bit-Release
+
+
+ true
+ QtProjectManager.QMakeBuildStep
+ false
+
+ false
+ false
+ true
+
+
+ true
+ Qt4ProjectManager.MakeStep
+
+ false
+
+
+ false
+
+ 2
+ Build
+ Build
+ ProjectExplorer.BuildSteps.Build
+
+
+
+ true
+ Qt4ProjectManager.MakeStep
+
+ true
+ clean
+
+ false
+
+ 1
+ Clean
+ Clean
+ ProjectExplorer.BuildSteps.Clean
+
+ 2
+ false
+
+ Release
+ Qt4ProjectManager.Qt4BuildConfiguration
+ 0
+
+
+ C:/Users/admin/Desktop/build-IntegratedPlatform-Desktop_Qt_5_14_2_MinGW_64_bit-Profile
+
+
+ true
+ QtProjectManager.QMakeBuildStep
+ true
+
+ false
+ true
+ true
+
+
+ true
+ Qt4ProjectManager.MakeStep
+
+ false
+
+
+ false
+
+ 2
+ Build
+ Build
+ ProjectExplorer.BuildSteps.Build
+
+
+
+ true
+ Qt4ProjectManager.MakeStep
+
+ true
+ clean
+
+ false
+
+ 1
+ Clean
+ Clean
+ ProjectExplorer.BuildSteps.Clean
+
+ 2
+ false
+
+ Profile
+ Qt4ProjectManager.Qt4BuildConfiguration
+ 0
+
+ 3
+
+
+ 0
+ Deploy
+ Deploy
+ ProjectExplorer.BuildSteps.Deploy
+
+ 1
+ ProjectExplorer.DefaultDeployConfiguration
+
+ 1
+
+
+ dwarf
+
+ cpu-cycles
+
+
+ 250
+
+ -e
+ cpu-cycles
+ --call-graph
+ dwarf,4096
+ -F
+ 250
+
+ -F
+ true
+ 4096
+ false
+ false
+ 1000
+
+ true
+
+ false
+ false
+ false
+ false
+ true
+ 0.01
+ 10
+ true
+ kcachegrind
+ 1
+ 25
+
+ 1
+ true
+ false
+ true
+ valgrind
+
+ 0
+ 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+ 10
+ 11
+ 12
+ 13
+ 14
+
+ 2
+
+
+ ProjectExplorer.CustomExecutableRunConfiguration
+
+
+ false
+
+ false
+ true
+ false
+ false
+ true
+
+
+
+ 1
+
+
+
+ ProjectExplorer.Project.TargetCount
+ 2
+
+
+ ProjectExplorer.Project.Updater.FileVersion
+ 22
+
+
+ Version
+ 22
+
+
diff --git a/IntegratedPlatform/hmiwidget.cpp b/IntegratedPlatform/hmiwidget.cpp
new file mode 100644
index 0000000..e69de29
diff --git a/IntegratedPlatform/hmiwidget.h b/IntegratedPlatform/hmiwidget.h
new file mode 100644
index 0000000..8afb1fd
--- /dev/null
+++ b/IntegratedPlatform/hmiwidget.h
@@ -0,0 +1,4 @@
+#ifndef HMIELEMENT_H
+#define HMIELEMENT_H
+
+#endif // HMIELEMENT_H
diff --git a/IntegratedPlatform/main.cpp b/IntegratedPlatform/main.cpp
new file mode 100644
index 0000000..2882dbf
--- /dev/null
+++ b/IntegratedPlatform/main.cpp
@@ -0,0 +1,12 @@
+#include "mainwindow.h"
+
+#include
+#include
+int main(int argc, char *argv[])
+{
+ QApplication::setStyle(QStyleFactory::create("Fusion"));
+ QApplication a(argc, argv);
+ MainWindow w;
+ w.show();
+ return a.exec();
+}
diff --git a/IntegratedPlatform/mainwindow.cpp b/IntegratedPlatform/mainwindow.cpp
new file mode 100644
index 0000000..1129a42
--- /dev/null
+++ b/IntegratedPlatform/mainwindow.cpp
@@ -0,0 +1,71 @@
+#include "mainwindow.h"
+#include "ui_mainwindow.h"
+
+MainWindow::MainWindow(QWidget *parent)
+ : QMainWindow(parent)
+ , ui(new Ui::MainWindow)
+ ,canDrawCircle(false)
+ ,canDrawRectangle(false)
+{
+ ui->setupUi(this);
+ scene = new QGraphicsScene(this);
+ ui->graphicsView_2->setScene(scene);
+ connect(ui->treeWidget_2, &QTreeWidget::itemClicked, this, &MainWindow::onHmiItemClicked);
+ ui-> graphicsView_2->viewport()->installEventFilter(this);
+ addDockWidget(Qt::BottomDockWidgetArea, ui->dockWidget_3);//将dockWidget_3添加到主窗口的下方
+
+ QList items = ui->treeWidget_2->findItems("指示灯", Qt::MatchExactly);
+ for (QTreeWidgetItem *item : items) {
+ item->setIcon(0, QIcon("C:/Users/admin/Desktop/T-常开触点-01.png"));
+ }
+}
+
+MainWindow::~MainWindow()
+{
+ delete ui;
+}
+
+void MainWindow::onHmiItemClicked(QTreeWidgetItem *item){
+ if (item->text(0) == "指示灯")
+ {
+ canDrawCircle = true;
+ canDrawRectangle = false;
+ }
+ else if(item->text(0) == "按钮")
+ {
+ canDrawCircle=false;
+ canDrawRectangle = true;//如果点击的是按钮,则不允许绘制灯
+ }
+ else {
+ canDrawRectangle = false;//如果点击的是灯,则不允许绘制按钮
+ canDrawCircle = false;
+ }
+}
+bool MainWindow::eventFilter(QObject *obj, QEvent *event)
+{
+ if (obj == ui->graphicsView_2->viewport() && event->type() == QEvent::MouseButtonPress) {
+ QMouseEvent *mouseEvent = static_cast(event);
+ if (mouseEvent->button() == Qt::LeftButton) {
+ // 获取点击的场景坐标
+ if (canDrawCircle)
+ {
+ QPointF scenePos = ui->graphicsView_2->mapToScene(mouseEvent->pos());// 在点击位置绘制一个指示灯
+ scene->addEllipse(scenePos.x(), scenePos.y(), 50, 50, QPen(Qt::black), QBrush(Qt::blue));
+ }
+ else if (canDrawRectangle)
+ {
+ QPointF scenePos = ui->graphicsView_2->mapToScene(mouseEvent->pos());//在点击位置绘制一个按钮
+ scene->addRect(scenePos.x(), scenePos.y(), 50, 50, QPen(Qt::black), QBrush(Qt::blue));
+ }
+ QTreeWidgetItem *selectedItem = ui->treeWidget_2->currentItem();
+ if (selectedItem)
+ {
+ selectedItem->setSelected(false);//取消选中当前项目
+ }
+ canDrawCircle = false;
+ canDrawRectangle = false;
+ return true;
+ }
+ return QMainWindow::eventFilter(obj, event);
+ }
+}
diff --git a/IntegratedPlatform/mainwindow.h b/IntegratedPlatform/mainwindow.h
new file mode 100644
index 0000000..ecf74ee
--- /dev/null
+++ b/IntegratedPlatform/mainwindow.h
@@ -0,0 +1,30 @@
+#ifndef MAINWINDOW_H
+#define MAINWINDOW_H
+
+#include
+#include
+#include
+#include
+
+QT_BEGIN_NAMESPACE
+namespace Ui { class MainWindow; }
+QT_END_NAMESPACE
+
+class MainWindow : public QMainWindow
+{
+ Q_OBJECT
+
+public:
+ MainWindow(QWidget *parent = nullptr);
+ ~MainWindow();
+private slots:
+ void onHmiItemClicked(QTreeWidgetItem *item);
+protected:
+ bool eventFilter(QObject *obj, QEvent *event) override;
+private:
+ Ui::MainWindow *ui;
+ bool canDrawCircle;
+ bool canDrawRectangle;
+ QGraphicsScene *scene; // QGraphicsScene,用于容纳图形项
+};
+#endif // MAINWINDOW_H
diff --git a/IntegratedPlatform/mainwindow.ui b/IntegratedPlatform/mainwindow.ui
new file mode 100644
index 0000000..4042b83
--- /dev/null
+++ b/IntegratedPlatform/mainwindow.ui
@@ -0,0 +1,312 @@
+
+
+ MainWindow
+
+
+
+ 0
+ 0
+ 952
+ 718
+
+
+
+ 综合平台编程器
+
+
+
+ -
+
+
+
+ Times New Roman
+ 12
+
+
+
+ 1
+
+
+
+ PLC 编程
+
+
+
-
+
+
+
+ 1
+ 1
+
+
+
+ QFrame::Plain
+
+
+ 1
+
+
+
+ -
+
+
+
+ 宋体
+ 12
+
+
+
+
+ 控件栏
+
+
+ AlignCenter
+
+
+
-
+
+ 常开
+
+
+ -
+
+ 常闭
+
+
+ -
+
+ 比较指令
+
+
+ -
+
+ 线圈
+
+
+
+
+
+
+
+
+ HMI 编程
+
+
+ -
+
+
+
+ 1
+ 1
+
+
+
+ false
+
+
+
+ -
+
+
+
+ 宋体
+ 18
+
+
+
+ QAbstractItemView::SingleSelection
+
+
+
+ 控件栏
+
+
+ AlignCenter
+
+
+
-
+
+ 指示灯
+
+
+ -
+
+ 按钮
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 0
+ 0
+
+
+
+
+ 宋体
+ 12
+
+
+
+ true
+
+
+ false
+
+
+ 消息
+
+
+ 1
+
+
+
+ -
+
+
+
+
+
+
+
+ 新建
+
+
+
+ 宋体
+ 12
+
+
+
+
+
+ 复制
+
+
+
+ 宋体
+ 12
+
+
+
+
+
+ RUN
+
+
+
+ Times New Roman
+ 12
+
+
+
+
+
+ 打开
+
+
+
+ 宋体
+ 12
+
+
+
+
+
+ 保存
+
+
+
+ 宋体
+ 12
+
+
+
+
+
+ 粘贴
+
+
+
+ 宋体
+ 12
+
+
+
+
+
+ 删除
+
+
+
+ 宋体
+ 12
+
+
+
+
+
+
+