diff options
author | Liang Qi <liang.qi@qt.io> | 2016-08-23 08:23:42 +0200 |
---|---|---|
committer | Liang Qi <liang.qi@qt.io> | 2016-08-23 09:13:20 +0200 |
commit | d352d707f95c3c4e213585361a3ec737389e301e (patch) | |
tree | 492cd77328b19731cecbd5470d9c667d78d75e79 /examples/charts/callout/callout.cpp | |
parent | a7b80c0b6176692ee2b7abdce7acdc5c37a72d00 (diff) | |
parent | 7a0be48ac39243d139cc4a78423ca033d5d90b3a (diff) |
Merge remote-tracking branch 'origin/5.6' into 5.7
Conflicts:
.qmake.conf
README
src/charts/qchartglobal.h
tests/auto/chartdataset/tst_chartdataset.cpp
tests/auto/domain/tst_domain.cpp
Change-Id: Ib4e01f2646d87b691c7b2f8bee4ed1f5521e4f6d
Diffstat (limited to 'examples/charts/callout/callout.cpp')
-rw-r--r-- | examples/charts/callout/callout.cpp | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/examples/charts/callout/callout.cpp b/examples/charts/callout/callout.cpp index 2c843393..bb37802a 100644 --- a/examples/charts/callout/callout.cpp +++ b/examples/charts/callout/callout.cpp @@ -32,15 +32,17 @@ #include <QtGui/QFontMetrics> #include <QtWidgets/QGraphicsSceneMouseEvent> #include <QtGui/QMouseEvent> +#include <QtCharts/QChart> -Callout::Callout(QGraphicsItem * parent): - QGraphicsItem(parent) +Callout::Callout(QChart *chart): + QGraphicsItem(chart), + m_chart(chart) { } QRectF Callout::boundingRect() const { - QPointF anchor = mapFromParent(m_anchor); + QPointF anchor = mapFromParent(m_chart->mapToPosition(m_anchor)); QRectF rect; rect.setLeft(qMin(m_rect.left(), anchor.x())); rect.setRight(qMax(m_rect.right(), anchor.x())); @@ -56,7 +58,7 @@ void Callout::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, Q QPainterPath path; path.addRoundedRect(m_rect, 5, 5); - QPointF anchor = mapFromParent(m_anchor); + QPointF anchor = mapFromParent(m_chart->mapToPosition(m_anchor)); if (!m_rect.contains(anchor)) { QPointF point1, point2; @@ -88,7 +90,7 @@ void Callout::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, Q point2.setY(y2); path.moveTo(point1); - path.lineTo(mapFromParent(m_anchor)); + path.lineTo(anchor); path.lineTo(point2); path = path.simplified(); } @@ -126,3 +128,9 @@ void Callout::setAnchor(QPointF point) { m_anchor = point; } + +void Callout::updateGeometry() +{ + prepareGeometryChange(); + setPos(m_chart->mapToPosition(m_anchor) + QPoint(10, -50)); +} |