fix: 重写通道勾选逻辑,clicked信号直接驱动显示/隐藏
- 改用clicked信号代替toggled,避免程序改动误触发 - 初始默认不勾选(setChecked(false)) - 勾选框样式优化:勾上蓝底,不勾灰色 - 勾选立即update()刷新图例+曲线
This commit is contained in:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user