summaryrefslogtreecommitdiffstats
path: root/examples/piechartdrilldown/drilldownslice.cpp
diff options
context:
space:
mode:
authorJani Honkonen <jani.honkonen@digia.com>2012-04-04 17:31:42 +0300
committerJani Honkonen <jani.honkonen@digia.com>2012-04-04 17:32:41 +0300
commit7f4e2249f98853756c838f64d08c03e03bafda36 (patch)
treeb799f203b6cdaedb874ce9452342511e79d04def /examples/piechartdrilldown/drilldownslice.cpp
parent3583c695b95eb80cf8a03ab6a00c2533b061a057 (diff)
Improving pie examples
Diffstat (limited to 'examples/piechartdrilldown/drilldownslice.cpp')
-rw-r--r--examples/piechartdrilldown/drilldownslice.cpp19
1 files changed, 16 insertions, 3 deletions
diff --git a/examples/piechartdrilldown/drilldownslice.cpp b/examples/piechartdrilldown/drilldownslice.cpp
index 45d8f160..6b8168c1 100644
--- a/examples/piechartdrilldown/drilldownslice.cpp
+++ b/examples/piechartdrilldown/drilldownslice.cpp
@@ -27,9 +27,10 @@ DrilldownSlice::DrilldownSlice(qreal value, QString prefix, QSeries* drilldownSe
m_prefix(prefix)
{
setValue(value);
- setLabelVisible(true);
updateLabel();
connect(this, SIGNAL(changed()), this, SLOT(updateLabel()));
+ connect(this, SIGNAL(hoverEnter()), this, SLOT(showHighlight()));
+ connect(this, SIGNAL(hoverLeave()), this, SLOT(hideHighlight()));
}
DrilldownSlice::~DrilldownSlice()
@@ -45,12 +46,24 @@ QSeries* DrilldownSlice::drilldownSeries() const
void DrilldownSlice::updateLabel()
{
QString label = m_prefix;
- label += " ";
+ label += " $";
label += QString::number(this->value());
- label += "e, ";
+ label += ", ";
label += QString::number(this->percentage()*100, 'f', 1);
label += "%";
setLabel(label);
}
+void DrilldownSlice::showHighlight()
+{
+ setExploded();
+ setLabelVisible();
+}
+
+void DrilldownSlice::hideHighlight()
+{
+ setExploded(false);
+ setLabelVisible(false);
+}
+
#include "moc_drilldownslice.cpp"