summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--examples/embedded/lightmaps/slippymap.cpp13
-rw-r--r--src/corelib/tools/qpoint.cpp14
-rw-r--r--src/corelib/tools/qpoint.h1
-rw-r--r--tests/auto/corelib/tools/qpoint/tst_qpoint.cpp3
-rw-r--r--tests/auto/gui/painting/qpainter/tst_qpainter.cpp5
5 files changed, 18 insertions, 18 deletions
diff --git a/examples/embedded/lightmaps/slippymap.cpp b/examples/embedded/lightmaps/slippymap.cpp
index 038738c69e..bd97aef7ee 100644
--- a/examples/embedded/lightmaps/slippymap.cpp
+++ b/examples/embedded/lightmaps/slippymap.cpp
@@ -53,19 +53,6 @@
#include "slippymap.h"
#include "qmath.h"
-#ifdef QT_NAMESPACE
-QT_BEGIN_NAMESPACE
-size_t qHash(const QT_NAMESPACE::QPoint& p)
-#else
-size_t qHash(const QPoint& p)
-#endif
-{
- return p.x() * 17 ^ p.y();
-}
-#ifdef QT_NAMESPACE
-QT_END_NAMESPACE
-#endif
-
// tile size in pixels
const int tdim = 256;
diff --git a/src/corelib/tools/qpoint.cpp b/src/corelib/tools/qpoint.cpp
index 432fb33297..eca1b5a0ac 100644
--- a/src/corelib/tools/qpoint.cpp
+++ b/src/corelib/tools/qpoint.cpp
@@ -41,6 +41,7 @@
#include "qdatastream.h"
#include <private/qdebug_p.h>
+#include <QtCore/qhashfunctions.h>
QT_BEGIN_NAMESPACE
@@ -484,6 +485,19 @@ QDebug operator<<(QDebug dbg, const QPointF &p)
#endif
/*!
+ \fn size_t qHash(QPoint key, size_t seed = 0)
+ \relates QHash
+ \since 6.0
+
+ Returns the hash value for the \a key, using \a seed to seed the
+ calculation.
+*/
+size_t qHash(QPoint key, size_t seed) noexcept
+{
+ return qHashMulti(seed, key.x(), key.y());
+}
+
+/*!
\class QPointF
\inmodule QtCore
\ingroup painting
diff --git a/src/corelib/tools/qpoint.h b/src/corelib/tools/qpoint.h
index 725787265f..e854e77198 100644
--- a/src/corelib/tools/qpoint.h
+++ b/src/corelib/tools/qpoint.h
@@ -214,6 +214,7 @@ constexpr inline const QPoint operator/(const QPoint &p, qreal c)
Q_CORE_EXPORT QDebug operator<<(QDebug, const QPoint &);
#endif
+Q_CORE_EXPORT size_t qHash(QPoint key, size_t seed = 0) noexcept;
diff --git a/tests/auto/corelib/tools/qpoint/tst_qpoint.cpp b/tests/auto/corelib/tools/qpoint/tst_qpoint.cpp
index f25492d2db..0f3edb3eed 100644
--- a/tests/auto/corelib/tools/qpoint/tst_qpoint.cpp
+++ b/tests/auto/corelib/tools/qpoint/tst_qpoint.cpp
@@ -346,6 +346,9 @@ void tst_QPoint::operator_eq()
QCOMPARE(equal, expectEqual);
bool notEqual = point1 != point2;
QCOMPARE(notEqual, !expectEqual);
+
+ if (equal)
+ QCOMPARE(qHash(point1), qHash(point2));
}
#ifndef QT_NO_DATASTREAM
diff --git a/tests/auto/gui/painting/qpainter/tst_qpainter.cpp b/tests/auto/gui/painting/qpainter/tst_qpainter.cpp
index 5d4e9def83..9c5a52f2d9 100644
--- a/tests/auto/gui/painting/qpainter/tst_qpainter.cpp
+++ b/tests/auto/gui/painting/qpainter/tst_qpainter.cpp
@@ -3256,11 +3256,6 @@ void tst_QPainter::imageScaling_task206785()
#define FOR_EACH_NEIGHBOR_8 for (int dx = -1; dx <= 1; ++dx) for (int dy = -1; dy <= 1; ++dy) if (dx != 0 || dy != 0)
#define FOR_EACH_NEIGHBOR_4 for (int dx = -1; dx <= 1; ++dx) for (int dy = -1; dy <= 1; ++dy) if ((dx == 0) != (dy == 0))
-size_t qHash(const QPoint &point)
-{
- return qHash(qMakePair(point.x(), point.y()));
-}
-
bool verifyOutlineFillConsistency(const QImage &img, QRgb outside, QRgb inside, QRgb outline)
{
if (img.pixel(img.width() / 2, img.height() / 2) != inside)