From 786b61dc6f56aea0e6567bac00965bb1d5259531 2012-09-20 15:36:19 From: Michal Klocek Date: 2012-09-20 15:36:19 Subject: [PATCH] fixes legend not vibile after showEvent --- diff --git a/src/legend/legendlayout.cpp b/src/legend/legendlayout.cpp index bd3a332..db8c05f 100644 --- a/src/legend/legendlayout.cpp +++ b/src/legend/legendlayout.cpp @@ -91,15 +91,14 @@ void LegendLayout::setGeometry(const QRectF& rect) { m_legend->d_ptr->items()->setVisible(m_legend->isVisible()); - if(m_legend->isAttachedToChart()) { + QGraphicsLayout::setGeometry(rect); + if(m_legend->isAttachedToChart()) { setAttachedGeometry(rect); - } - else { + } else { setDettachedGeometry(rect); } - QGraphicsLayout::setGeometry(rect); } void LegendLayout::setAttachedGeometry(const QRectF& rect) diff --git a/src/legend/qlegend.cpp b/src/legend/qlegend.cpp index c61ecf9..67c795d 100644 --- a/src/legend/qlegend.cpp +++ b/src/legend/qlegend.cpp @@ -336,7 +336,6 @@ void QLegend::setAlignment(Qt::Alignment alignment) { if(d_ptr->m_alignment!=alignment) { d_ptr->m_alignment = alignment; - updateGeometry(); if(isAttachedToChart()){ d_ptr->m_presenter->layout()->invalidate(); }else{ @@ -404,7 +403,7 @@ bool QLegend::isBackgroundVisible() const */ void QLegend::hideEvent(QHideEvent *event) { - d_ptr->m_presenter->layout()->invalidate(); + if(isAttachedToChart()) d_ptr->m_presenter->layout()->invalidate(); QGraphicsWidget::hideEvent(event); } @@ -413,9 +412,12 @@ void QLegend::hideEvent(QHideEvent *event) */ void QLegend::showEvent(QShowEvent *event) { + if(isAttachedToChart()) { + d_ptr->m_presenter->layout()->invalidate(); + d_ptr->items()->setVisible(false); + layout()->invalidate(); + } QGraphicsWidget::showEvent(event); - d_ptr->m_presenter->layout()->invalidate(); - d_ptr->items()->setVisible(false); //layout activation will show the items }