summaryrefslogtreecommitdiffstats
path: root/examples/widgets/graphicsview/elasticnodes/edge.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'examples/widgets/graphicsview/elasticnodes/edge.cpp')
-rw-r--r--examples/widgets/graphicsview/elasticnodes/edge.cpp7
1 files changed, 2 insertions, 5 deletions
diff --git a/examples/widgets/graphicsview/elasticnodes/edge.cpp b/examples/widgets/graphicsview/elasticnodes/edge.cpp
index e794e803cf..d9e4c62e34 100644
--- a/examples/widgets/graphicsview/elasticnodes/edge.cpp
+++ b/examples/widgets/graphicsview/elasticnodes/edge.cpp
@@ -51,12 +51,11 @@
#include "edge.h"
#include "node.h"
-#include <math.h>
+#include <cmath>
#include <QPainter>
static const double Pi = 3.14159265358979323846264338327950288419717;
-static double TwoPi = 2.0 * Pi;
//! [0]
Edge::Edge(Node *sourceNode, Node *destNode)
@@ -139,9 +138,7 @@ void Edge::paint(QPainter *painter, const QStyleOptionGraphicsItem *, QWidget *)
//! [6]
// Draw the arrows
- double angle = ::acos(line.dx() / line.length());
- if (line.dy() >= 0)
- angle = TwoPi - angle;
+ double angle = std::atan2(-line.dy(), line.dx());
QPointF sourceArrowP1 = sourcePoint + QPointF(sin(angle + Pi / 3) * arrowSize,
cos(angle + Pi / 3) * arrowSize);