diff --git a/plotwidget.cpp b/plotwidget.cpp index af3adaa..b6178c1 100644 --- a/plotwidget.cpp +++ b/plotwidget.cpp @@ -101,6 +101,7 @@ void PlotWidget::setChannelVisible(int channel, bool visible) if (channel >= 0 && channel < 16) { m_channelVisible[channel] = visible; m_dirty = true; + update(); // 立即刷新,不等定时器 } } @@ -381,13 +382,17 @@ void PlotWidget::drawLegend(QPainter &painter) for (int ch = 0; ch < 16; ++ch) { int y = legendY + ch * itemHeight; - // 颜色方块 - QColor color = m_channelVisible[ch] ? m_colors[ch] : QColor("#444444"); + // 颜色方块:勾选=彩色,不勾选=灰白 + QColor color = m_channelVisible[ch] ? m_colors[ch] : QColor("#555555"); painter.fillRect(QRect(legendX, y + 2, 12, 12), color); + if (!m_channelVisible[ch]) { + painter.setPen(QPen(QColor("#888888"), 1)); + painter.drawRect(QRect(legendX, y + 2, 12, 12)); + } // 通道名 QString label = QString("ch%1").arg(ch); - painter.setPen(m_channelVisible[ch] ? m_textColor : QColor("#666666")); + painter.setPen(m_channelVisible[ch] ? m_textColor : QColor("#555555")); painter.drawText(QRect(legendX + 16, y, 50, itemHeight), Qt::AlignLeft | Qt::AlignVCenter, label); }