summaryrefslogtreecommitdiffstats
path: root/src/corelib/kernel/qmetatype.h
diff options
context:
space:
mode:
authorMårten Nordheim <marten.nordheim@qt.io>2022-04-04 19:40:52 +0200
committerMårten Nordheim <marten.nordheim@qt.io>2022-04-05 17:24:28 +0000
commitd72f2ca9ea5e8bc7357f457370b2eb039bb48a2f (patch)
tree55627084ae90febc8a9499c5f0143caeece2cfc7 /src/corelib/kernel/qmetatype.h
parentd2d202c64870e56f6ac3f802abe6c9c978136f53 (diff)
QMetaType: Add qHash() overload
This is needed for use in QHash and similar. It's essentially the same as using the integer id, but typesafe Change-Id: I9515b8e178c8f9828934cb0bb099cce5553ec393 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Marc Mutz <marc.mutz@qt.io>
Diffstat (limited to 'src/corelib/kernel/qmetatype.h')
-rw-r--r--src/corelib/kernel/qmetatype.h8
1 files changed, 8 insertions, 0 deletions
diff --git a/src/corelib/kernel/qmetatype.h b/src/corelib/kernel/qmetatype.h
index a8962f8b57..8b52752470 100644
--- a/src/corelib/kernel/qmetatype.h
+++ b/src/corelib/kernel/qmetatype.h
@@ -52,6 +52,7 @@
#ifndef QT_NO_QOBJECT
#include <QtCore/qobjectdefs.h>
#endif
+#include <QtCore/qhashfunctions.h>
#include <array>
#include <new>
@@ -2536,6 +2537,13 @@ constexpr const QtPrivate::QMetaTypeInterface *const qt_incomplete_metaTypeArray
QtPrivate::qTryMetaTypeInterfaceForType<Unique, T>()...
};
+inline size_t qHash(QMetaType type, size_t seed = 0)
+{
+ // We cannot use d_ptr here since the same type in different DLLs
+ // might result in different pointers!
+ return qHash(type.id(), seed);
+}
+
QT_END_NAMESPACE
QT_DECL_METATYPE_EXTERN_TAGGED(QtMetaTypePrivate::QPairVariantInterfaceImpl,