From 703758f6d2cfa191adba418e98bea21031ac4e1d 2012-04-04 13:37:29 From: sauimone Date: 2012-04-04 13:37:29 Subject: [PATCH] changed legend default visibility --- diff --git a/src/qlegend.cpp b/src/qlegend.cpp index b2b325a..357cb5c 100644 --- a/src/qlegend.cpp +++ b/src/qlegend.cpp @@ -100,10 +100,11 @@ QLegend::QLegend(QChart *chart):QGraphicsWidget(chart), m_minHeight(0), m_width(0), m_height(0), - m_visible(false) + m_backgroundVisible(false) { setZValue(ChartPresenter::LegendZValue); setFlags(QGraphicsItem::ItemClipsChildrenToShape); + setVisible(false); // By default legend is invisible } /*! @@ -114,7 +115,7 @@ void QLegend::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, Q { Q_UNUSED(option) Q_UNUSED(widget) - if(!m_visible) return; + if(!m_backgroundVisible) return; painter->setOpacity(opacity()); painter->setPen(m_pen); @@ -482,16 +483,16 @@ void QLegend::updateLayout() void QLegend::setBackgroundVisible(bool visible) { - if(m_visible!=visible) + if(m_backgroundVisible!=visible) { - m_visible=visible; + m_backgroundVisible=visible; update(); } } bool QLegend::isBackgroundVisible() const { - return m_visible; + return m_backgroundVisible; } void QLegend::resizeEvent(QGraphicsSceneResizeEvent *event) diff --git a/src/qlegend.h b/src/qlegend.h index ffcef85..f40efeb 100644 --- a/src/qlegend.h +++ b/src/qlegend.h @@ -80,7 +80,7 @@ public: qreal minWidht() const { return m_minWidth;} qreal minHeight() const { return m_minHeight;} - void setBackgroundVisible(bool visible); + void setBackgroundVisible(bool visible = true); bool isBackgroundVisible() const; void setOffset(const QPointF& point); @@ -130,7 +130,7 @@ private: qreal m_minHeight; qreal m_width; qreal m_height; - bool m_visible; + bool m_backgroundVisible; friend class ScrolledQLegend; // <--- PIMPL };