summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorKeith Kyzivat <keith.kyzivat@qt.io>2021-03-08 14:53:12 -0500
committerKeith Kyzivat <keith.kyzivat@qt.io>2021-05-28 13:36:14 -0400
commit71b30b24cf6981ed3d79b3cdb781ee0d4a65d9b2 (patch)
treec2cbfed5566ad99c56b9323b710b49cd283228bd /src
parent3c9b56520ab3c38dbf3db53556c75af1b62db1c8 (diff)
Add QLegend::attachedToChartChanged signal
This will allow users to hook into when the legend is attached or detached. Task-number: QTBUG-93981 Change-Id: I3a0258a6c4c82a1feb005ac2df95a11e6f96d509 Reviewed-by: Miikka Heikkinen <miikka.heikkinen@qt.io>
Diffstat (limited to 'src')
-rw-r--r--src/charts/legend/qlegend.cpp15
-rw-r--r--src/charts/legend/qlegend.h1
2 files changed, 14 insertions, 2 deletions
diff --git a/src/charts/legend/qlegend.cpp b/src/charts/legend/qlegend.cpp
index 16559db1..90fd3458 100644
--- a/src/charts/legend/qlegend.cpp
+++ b/src/charts/legend/qlegend.cpp
@@ -235,6 +235,12 @@ QT_BEGIN_NAMESPACE
*/
/*!
+ \fn void QLegend::attachedToChartChanged(bool)
+ This signal is emitted when the legend is attached to or detached from the legend.
+ \since 6.2
+*/
+
+/*!
\fn void QLegend::backgroundVisibleChanged(bool)
This signal is emitted when the visibility of the legend background changes to \a visible.
*/
@@ -465,11 +471,13 @@ Qt::Alignment QLegend::alignment() const
*/
void QLegend::detachFromChart()
{
+ bool changed = d_ptr->m_attachedToChart == true;
d_ptr->m_attachedToChart = false;
-// layout()->invalidate();
d_ptr->m_chart->layout()->invalidate();
setParent(0);
+ if (changed)
+ emit attachedToChartChanged(false);
}
/*!
@@ -477,10 +485,13 @@ void QLegend::detachFromChart()
*/
void QLegend::attachToChart()
{
+ bool changed = d_ptr->m_attachedToChart == false;
d_ptr->m_attachedToChart = true;
-// layout()->invalidate();
d_ptr->m_chart->layout()->invalidate();
setParent(d_ptr->m_chart);
+
+ if (changed)
+ emit attachedToChartChanged(true);
}
/*!
diff --git a/src/charts/legend/qlegend.h b/src/charts/legend/qlegend.h
index fc79086a..5f36cfd3 100644
--- a/src/charts/legend/qlegend.h
+++ b/src/charts/legend/qlegend.h
@@ -127,6 +127,7 @@ Q_SIGNALS:
void reverseMarkersChanged(bool reverseMarkers);
void showToolTipsChanged(bool showToolTips);
void markerShapeChanged(MarkerShape shape);
+ Q_REVISION(6, 2) void attachedToChartChanged(bool attachedToChart);
private:
QScopedPointer<QLegendPrivate> d_ptr;