From b6cd730feb26b41304bf9c89c51986bb423b718b Mon Sep 17 00:00:00 2001 From: iorebuild Date: Thu, 30 Apr 2026 13:09:01 +0800 Subject: [PATCH] =?UTF-8?q?refactor:=20=E5=8E=BB=E6=8E=89=E5=A4=9A?= =?UTF-8?q?=E4=BD=99=E7=9A=84=E6=98=BE=E7=A4=BA=E7=82=B9=E6=95=B0=E6=8E=A7?= =?UTF-8?q?=E4=BB=B6=EF=BC=8C=E6=9D=A5=E4=B8=80=E4=B8=AA=E7=82=B9=E7=94=BB?= =?UTF-8?q?=E4=B8=80=E4=B8=AA=E7=82=B9=EF=BC=8C=E8=87=AA=E5=8A=A8=E6=BB=9A?= =?UTF-8?q?=E5=8A=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 移除SpinBox和onDisplayPointsChanged - 内部滚动窗口固定3000个点,数据无限追加 - 收到UDP包立即刷新绘图 --- mainwindow.cpp | 22 ---------------------- mainwindow.h | 3 --- plotwidget.cpp | 2 +- 3 files changed, 1 insertion(+), 26 deletions(-) diff --git a/mainwindow.cpp b/mainwindow.cpp index 8643a31..a558d89 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -79,29 +79,12 @@ void MainWindow::setupUi() ); connect(m_clearBtn, &QPushButton::clicked, this, &MainWindow::onClear); - QLabel *displayLabel = new QLabel("显示点数:"); - displayLabel->setStyleSheet("color: #ccc; font-size: 13px;"); - - m_displaySpinBox = new QSpinBox(); - m_displaySpinBox->setRange(50, 10000); - m_displaySpinBox->setValue(500); - m_displaySpinBox->setSingleStep(100); - m_displaySpinBox->setStyleSheet( - "QSpinBox { background: #2a2a3e; color: #fff; border: 1px solid #555; " - "border-radius: 4px; padding: 4px; font-size: 13px; }" - ); - connect(m_displaySpinBox, static_cast(&QSpinBox::valueChanged), - this, &MainWindow::onDisplayPointsChanged); - controlLayout->addWidget(portLabel); controlLayout->addWidget(m_portEdit); controlLayout->addWidget(m_startStopBtn); controlLayout->addSpacing(20); controlLayout->addWidget(m_openFileBtn); controlLayout->addWidget(m_clearBtn); - controlLayout->addSpacing(20); - controlLayout->addWidget(displayLabel); - controlLayout->addWidget(m_displaySpinBox); controlLayout->addStretch(); mainLayout->addLayout(controlLayout); @@ -321,11 +304,6 @@ void MainWindow::processDataLine(const QString &line) m_packetLabel->setText(QString("收到: %1 包").arg(m_packetCount)); } -void MainWindow::onDisplayPointsChanged(int count) -{ - m_plotWidget->setDisplayPointCount(count); -} - void MainWindow::onToggleChannel(int channel, bool visible) { m_plotWidget->setChannelVisible(channel, visible); diff --git a/mainwindow.h b/mainwindow.h index 6ddeba9..b165286 100644 --- a/mainwindow.h +++ b/mainwindow.h @@ -10,7 +10,6 @@ #include #include #include -#include #include #include @@ -31,7 +30,6 @@ private slots: void onOpenFile(); void onClear(); void onDataReceived(const QByteArray &data); - void onDisplayPointsChanged(int count); void onToggleChannel(int channel, bool visible); private: @@ -48,7 +46,6 @@ private: QPushButton *m_clearBtn; QLabel *m_statusLabel; QLabel *m_packetLabel; - QSpinBox *m_displaySpinBox; PlotWidget *m_plotWidget; // 功能组件 diff --git a/plotwidget.cpp b/plotwidget.cpp index 906911f..adfb241 100644 --- a/plotwidget.cpp +++ b/plotwidget.cpp @@ -8,7 +8,7 @@ PlotWidget::PlotWidget(QWidget *parent) : QWidget(parent) , m_totalPoints(0) - , m_displayPoints(500) + , m_displayPoints(3000) , m_yMin(0) , m_yMax(65535) , m_autoYRange(true)