summaryrefslogtreecommitdiffstats
path: root/src/corelib/tools/qpoint.cpp
diff options
context:
space:
mode:
authorGunnar Sletta <gunnar@trolltech.com>2009-04-15 10:01:36 (GMT)
committerGunnar Sletta <gunnar@trolltech.com>2009-04-15 10:05:42 (GMT)
commit79891d8284736dc318cff8d9c3f6d7a6e87affd9 (patch)
treefe053e870f19f4f2cb218a7d4a6a986e001db7dd /src/corelib/tools/qpoint.cpp
parent0d7f704856166aea83843697ae98bdcf22dbabb0 (diff)
downloadQt-79891d8284736dc318cff8d9c3f6d7a6e87affd9.zip
Qt-79891d8284736dc318cff8d9c3f6d7a6e87affd9.tar.gz
Qt-79891d8284736dc318cff8d9c3f6d7a6e87affd9.tar.bz2
Introduce QPointF::manhattanLength
Task-number: 251068
Diffstat (limited to 'src/corelib/tools/qpoint.cpp')
-rw-r--r--src/corelib/tools/qpoint.cpp13
1 files changed, 13 insertions, 0 deletions
diff --git a/src/corelib/tools/qpoint.cpp b/src/corelib/tools/qpoint.cpp
index feea473..5cc71d6 100644
--- a/src/corelib/tools/qpoint.cpp
+++ b/src/corelib/tools/qpoint.cpp
@@ -442,6 +442,19 @@ QDebug operator<<(QDebug d, const QPointF &p)
otherwise returns false.
*/
+
+/*!
+ Returns the sum of the absolute values of x() and y(),
+ traditionally known as the "Manhattan length" of the vector from
+ the origin to the point.
+
+ \sa QPoint::manhattanLength()
+*/
+qreal QPointF::manhattanLength() const
+{
+ return qAbs(x())+qAbs(y());
+}
+
/*!
\fn qreal QPointF::x() const