summaryrefslogtreecommitdiffstats
path: root/examples
diff options
context:
space:
mode:
authorMarek Rosa <marek.rosa@digia.com>2012-12-04 10:50:59 +0200
committerMarek Rosa <marek.rosa@digia.com>2012-12-04 10:50:59 +0200
commitbf21d64b0d3dd1c93946e32d42a7a0c2573177db (patch)
treeec2cc688458b7c94e98fbe94bbdc5eac19ed0bac /examples
parentcd130a1062f282e14404c66304412b259e064c5e (diff)
Mapping functions added to QChart. Callout example updated
Diffstat (limited to 'examples')
-rw-r--r--examples/callout/callout.cpp6
-rw-r--r--examples/callout/widget.cpp7
2 files changed, 7 insertions, 6 deletions
diff --git a/examples/callout/callout.cpp b/examples/callout/callout.cpp
index 337ed5d4..5a26da34 100644
--- a/examples/callout/callout.cpp
+++ b/examples/callout/callout.cpp
@@ -14,9 +14,9 @@ QRectF Callout::boundingRect() const
QPointF anchor = mapFromParent(m_anchor);
QRectF rect;
rect.setLeft(qMin(m_textRect.left(), anchor.x()));
- rect.setRight(qMax(m_textRect.right() + 4, anchor.x()));
+ rect.setRight(qMax(m_textRect.right() + 8, anchor.x()));
rect.setTop(qMin(m_textRect.top(), anchor.y()));
- rect.setBottom(qMax(m_textRect.bottom() + 4, anchor.y()));
+ rect.setBottom(qMax(m_textRect.bottom() + 8, anchor.y()));
return rect;
}
@@ -65,7 +65,7 @@ void Callout::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, Q
}
painter->setBrush(QColor(255, 255, 255));
painter->drawPath(path);
- painter->drawText(m_textRect.adjusted(2, 2, 0, 0), m_text);
+ painter->drawText(m_textRect.adjusted(4, 4, 0, 0), m_text);
}
void Callout::mousePressEvent(QGraphicsSceneMouseEvent *event)
diff --git a/examples/callout/widget.cpp b/examples/callout/widget.cpp
index 5b722805..d0ac439f 100644
--- a/examples/callout/widget.cpp
+++ b/examples/callout/widget.cpp
@@ -73,9 +73,10 @@ void Widget::tooltip(QPointF point, bool state)
m_tooltip = new Callout(m_chart);
if (state) {
- m_tooltip->setText(QString("X: %1\nY: %2").arg(point.x()).arg(point.y()));
- m_tooltip->setAnchor(m_chart->mapFromParent(m_view->mapToScene(m_view->mapFromGlobal(QCursor::pos()))));
- m_tooltip->setPos(m_chart->mapFromParent(m_view->mapToScene(m_view->mapFromGlobal(QCursor::pos() + QPoint(10, -50)))));
+ m_tooltip->setText(QString("X: %1 \nY: %2 ").arg(point.x()).arg(point.y()));
+ QXYSeries *series = qobject_cast<QXYSeries *>(sender());
+ m_tooltip->setAnchor(m_chart->mapToPosition(point, series));
+ m_tooltip->setPos(m_chart->mapToPosition(point, series) + QPoint(10, -50));
m_tooltip->setZValue(11);
m_tooltip->show();
} else {