From 3d55adbab2dfba6e90bacc932f51d3308cbc660a Mon Sep 17 00:00:00 2001 From: iorebuild Date: Thu, 30 Apr 2026 13:38:38 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E9=87=8D=E5=86=99=E9=80=9A=E9=81=93?= =?UTF-8?q?=E5=8B=BE=E9=80=89=E9=80=BB=E8=BE=91=EF=BC=8Cclicked=E4=BF=A1?= =?UTF-8?q?=E5=8F=B7=E7=9B=B4=E6=8E=A5=E9=A9=B1=E5=8A=A8=E6=98=BE=E7=A4=BA?= =?UTF-8?q?/=E9=9A=90=E8=97=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 改用clicked信号代替toggled,避免程序改动误触发 - 初始默认不勾选(setChecked(false)) - 勾选框样式优化:勾上蓝底,不勾灰色 - 勾选立即update()刷新图例+曲线 --- mainwindow.cpp | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/mainwindow.cpp b/mainwindow.cpp index a558d89..4e8f5dc 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -109,15 +109,17 @@ void MainWindow::setupUi() channelLayout->setSpacing(2); for (int i = 0; i < 16; ++i) { - QCheckBox *check = new QCheckBox(QString("ch%1").arg(i)); - check->setChecked(true); + QCheckBox *check = new QCheckBox(QString("CH%1").arg(i+1)); + check->setChecked(false); check->setStyleSheet( "QCheckBox { color: #aaa; font-size: 11px; spacing: 4px; }" - "QCheckBox::indicator { width: 12px; height: 12px; }" - "QCheckBox::indicator:checked { background: #3498db; }" + "QCheckBox::indicator { width: 14px; height: 14px; }" + "QCheckBox::indicator:checked { background-color: #3498db; border: 1px solid #2980b9; }" + "QCheckBox::indicator:unchecked { background-color: #333; border: 1px solid #555; }" ); - connect(check, &QCheckBox::toggled, this, [this, i](bool checked) { - onToggleChannel(i, checked); + connect(check, &QCheckBox::clicked, this, [this, i](bool checked) { + m_plotWidget->setChannelVisible(i, checked); + m_plotWidget->update(); }); channelLayout->addWidget(check); m_channelChecks.append(check);