refactor: 改用qmake(.pro)构建,兼容Qt 5.9
- 移除CMakeLists.txt,改用AiAnalysis.pro - 修复Qt 5.9兼容性:QWheelEvent::posF()、QString::SkipEmptyParts、static_cast信号连接 - 更新README为qmake构建说明 - 删除CMake build目录
This commit is contained in:
24
AiAnalysis.pro
Normal file
24
AiAnalysis.pro
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
QT += core gui network
|
||||||
|
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
|
||||||
|
|
||||||
|
TARGET = AiAnalysis
|
||||||
|
TEMPLATE = app
|
||||||
|
|
||||||
|
CONFIG += c++11
|
||||||
|
|
||||||
|
# Qt 5.9 兼容,不使用 c++17
|
||||||
|
*-g++*: QMAKE_CXXFLAGS += -std=c++11
|
||||||
|
*-msvc*: QMAKE_CXXFLAGS += /std:c++11
|
||||||
|
|
||||||
|
SOURCES += \
|
||||||
|
main.cpp \
|
||||||
|
mainwindow.cpp \
|
||||||
|
udpreceiver.cpp \
|
||||||
|
plotwidget.cpp \
|
||||||
|
datamanager.cpp
|
||||||
|
|
||||||
|
HEADERS += \
|
||||||
|
mainwindow.h \
|
||||||
|
udpreceiver.h \
|
||||||
|
plotwidget.h \
|
||||||
|
datamanager.h
|
||||||
@@ -1,22 +0,0 @@
|
|||||||
cmake_minimum_required(VERSION 3.14)
|
|
||||||
project(AiAnalysis LANGUAGES CXX)
|
|
||||||
|
|
||||||
set(CMAKE_CXX_STANDARD 17)
|
|
||||||
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
|
||||||
set(CMAKE_AUTOMOC ON)
|
|
||||||
|
|
||||||
find_package(Qt5 REQUIRED COMPONENTS Core Widgets Network)
|
|
||||||
|
|
||||||
add_executable(AiAnalysis
|
|
||||||
main.cpp
|
|
||||||
mainwindow.cpp
|
|
||||||
mainwindow.h
|
|
||||||
udpreceiver.cpp
|
|
||||||
udpreceiver.h
|
|
||||||
plotwidget.cpp
|
|
||||||
plotwidget.h
|
|
||||||
datamanager.cpp
|
|
||||||
datamanager.h
|
|
||||||
)
|
|
||||||
|
|
||||||
target_link_libraries(AiAnalysis Qt5::Core Qt5::Widgets Qt5::Network)
|
|
||||||
50
README.md
50
README.md
@@ -12,52 +12,30 @@
|
|||||||
## 跨平台支持
|
## 跨平台支持
|
||||||
✅ Linux ✅ Windows ✅ macOS
|
✅ Linux ✅ Windows ✅ macOS
|
||||||
|
|
||||||
代码纯Qt5编写,无平台特定依赖。
|
纯Qt5 + qmake构建,无额外依赖。支持 Qt 5.9+。
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
## Windows 编译 & 运行
|
## Windows / Linux / macOS 编译 & 运行
|
||||||
|
|
||||||
### 准备工作
|
### Qt Creator(推荐)
|
||||||
1. 下载安装 **Qt 5.15** (MinGW 或 MSVC 版本均支持): https://download.qt.io/archive/qt/5.15/
|
|
||||||
- 安装时勾选 `MinGW` 编译器 或 `MSVC` 编译器
|
|
||||||
2. 下载安装 **CMake** (3.14+): https://cmake.org/download/
|
|
||||||
- 安装时勾选 "Add CMake to system PATH"
|
|
||||||
|
|
||||||
### 编译(命令行)
|
|
||||||
```powershell
|
|
||||||
# 在项目目录下
|
|
||||||
mkdir build
|
|
||||||
cd build
|
|
||||||
cmake .. -G "MinGW Makefiles"
|
|
||||||
mingw32-make -j4
|
|
||||||
# 或使用 MSVC:
|
|
||||||
# cmake .. -G "Visual Studio 17 2022"
|
|
||||||
```
|
|
||||||
|
|
||||||
### 编译(Qt Creator)
|
|
||||||
1. 打开 Qt Creator
|
1. 打开 Qt Creator
|
||||||
2. File → Open File or Project → 选择 `CMakeLists.txt`
|
2. **File → Open File or Project** → 选择 `AiAnalysis.pro`
|
||||||
3. 选择对应的 Kit(MinGW 64-bit 或 MSVC)
|
3. 选择对应的 Kit(如 Desktop Qt 5.9.8 MinGW 32bit)
|
||||||
4. 点击构建 → 运行
|
4. 点击左下角🔨构建 → ▶️运行
|
||||||
|
|
||||||
### 直接运行
|
### 命令行(qmake)
|
||||||
编译完成后,`build/AiAnalysis.exe` 即为可执行文件。
|
```bash
|
||||||
|
qmake AiAnalysis.pro
|
||||||
|
make -j4 # Linux/macOS
|
||||||
|
mingw32-make -j4 # Windows MinGW
|
||||||
|
```
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
## Linux 编译
|
|
||||||
```bash
|
|
||||||
sudo apt install qtbase5-dev cmake g++
|
|
||||||
mkdir build && cd build
|
|
||||||
cmake ..
|
|
||||||
make -j$(nproc)
|
|
||||||
./AiAnalysis
|
|
||||||
```
|
|
||||||
|
|
||||||
## 使用说明
|
## 使用说明
|
||||||
1. 输入UDP端口号,点击「开始监听」
|
1. 输入UDP端口号,点击「开始监听」
|
||||||
2. 下位机通过UDP发送逗号分隔的16通道数据
|
2. 下位机通过UDP发送逗号分隔的16通道数据,如:`17309,13624,17301,...`
|
||||||
3. 右侧面板可切换通道显示/隐藏
|
3. 右侧面板可切换通道显示/隐藏
|
||||||
4. 「打开文件」可加载历史CSV数据回放
|
4. 「打开文件」可加载历史CSV数据回放
|
||||||
5. 鼠标滚轮缩放Y轴,右键拖拽平移,双击恢复自动范围
|
5. 滚轮缩放Y轴 | 右键拖拽平移 | 双击恢复自动范围
|
||||||
|
|||||||
@@ -90,7 +90,7 @@ void MainWindow::setupUi()
|
|||||||
"QSpinBox { background: #2a2a3e; color: #fff; border: 1px solid #555; "
|
"QSpinBox { background: #2a2a3e; color: #fff; border: 1px solid #555; "
|
||||||
"border-radius: 4px; padding: 4px; font-size: 13px; }"
|
"border-radius: 4px; padding: 4px; font-size: 13px; }"
|
||||||
);
|
);
|
||||||
connect(m_displaySpinBox, QOverload<int>::of(&QSpinBox::valueChanged),
|
connect(m_displaySpinBox, static_cast<void(QSpinBox::*)(int)>(&QSpinBox::valueChanged),
|
||||||
this, &MainWindow::onDisplayPointsChanged);
|
this, &MainWindow::onDisplayPointsChanged);
|
||||||
|
|
||||||
controlLayout->addWidget(portLabel);
|
controlLayout->addWidget(portLabel);
|
||||||
@@ -284,7 +284,7 @@ void MainWindow::onDataReceived(const QByteArray &data)
|
|||||||
if (raw.isEmpty()) return;
|
if (raw.isEmpty()) return;
|
||||||
|
|
||||||
// 可能一个UDP包包含多行
|
// 可能一个UDP包包含多行
|
||||||
QStringList lines = raw.split('\n', Qt::SkipEmptyParts);
|
QStringList lines = raw.split('\n', QString::SkipEmptyParts);
|
||||||
for (const QString &line : lines) {
|
for (const QString &line : lines) {
|
||||||
processDataLine(line.trimmed());
|
processDataLine(line.trimmed());
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -394,7 +394,7 @@ void PlotWidget::drawLegend(QPainter &painter)
|
|||||||
void PlotWidget::wheelEvent(QWheelEvent *event)
|
void PlotWidget::wheelEvent(QWheelEvent *event)
|
||||||
{
|
{
|
||||||
QRectF area = plotArea();
|
QRectF area = plotArea();
|
||||||
if (!area.contains(event->position())) return;
|
if (!area.contains(event->posF())) return;
|
||||||
|
|
||||||
double zoomFactor = 1.15;
|
double zoomFactor = 1.15;
|
||||||
if (event->angleDelta().y() < 0) {
|
if (event->angleDelta().y() < 0) {
|
||||||
|
|||||||
Reference in New Issue
Block a user