summaryrefslogtreecommitdiffstats
path: root/examples/charts/chartsgallery/pcccustomslice.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'examples/charts/chartsgallery/pcccustomslice.cpp')
-rw-r--r--examples/charts/chartsgallery/pcccustomslice.cpp27
1 files changed, 27 insertions, 0 deletions
diff --git a/examples/charts/chartsgallery/pcccustomslice.cpp b/examples/charts/chartsgallery/pcccustomslice.cpp
new file mode 100644
index 00000000..6b4857b6
--- /dev/null
+++ b/examples/charts/chartsgallery/pcccustomslice.cpp
@@ -0,0 +1,27 @@
+// Copyright (C) 2023 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
+
+#include "pcccustomslice.h"
+
+PccCustomSlice::PccCustomSlice(const QString &label, qreal value)
+ : QPieSlice(label, value)
+{
+ connect(this, &PccCustomSlice::hovered, this, &PccCustomSlice::showHighlight);
+}
+
+QBrush PccCustomSlice::originalBrush()
+{
+ return m_originalBrush;
+}
+
+void PccCustomSlice::showHighlight(bool show)
+{
+ if (show) {
+ QBrush brush = this->brush();
+ m_originalBrush = brush;
+ brush.setColor(brush.color().lighter());
+ setBrush(brush);
+ } else {
+ setBrush(m_originalBrush);
+ }
+}