refactor: 去掉多余的显示点数控件,来一个点画一个点,自动滚动

- 移除SpinBox和onDisplayPointsChanged
- 内部滚动窗口固定3000个点,数据无限追加
- 收到UDP包立即刷新绘图
This commit is contained in:
iorebuild
2026-04-30 13:09:01 +08:00
parent 15a7685a2b
commit b6cd730feb
3 changed files with 1 additions and 26 deletions

View File

@@ -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<void(QSpinBox::*)(int)>(&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);

View File

@@ -10,7 +10,6 @@
#include <QHBoxLayout>
#include <QGridLayout>
#include <QGroupBox>
#include <QSpinBox>
#include <QFileDialog>
#include <QMessageBox>
@@ -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;
// 功能组件

View File

@@ -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)