path: root/src
diff options
authorJędrzej Nowacki <>2012-03-06 15:12:06 +0100
committerQt by Nokia <>2012-03-07 12:31:46 +0100
commit7439fb47cd7c5731dd1aadeaf10c46b58aa59798 (patch)
treea5ea8f5d7cf4e8dac8a765977fcf2ed93494dd14 /src
parentf72cbc7ce476b48f75a2b8b31c3e3ea0ac96bd11 (diff)
Add nicer error message in qMetaTypeId function.
The function can be used only with a registered type and it would fail to compile for other types. By adding the static assert we can print an almost user friendly compilation error message. Change-Id: I59ab148cabf32afe0baef186b82cb03303b57780 Reviewed-by: Stephen Kelly <> Reviewed-by: Olivier Goffart <>
Diffstat (limited to 'src')
1 files changed, 1 insertions, 0 deletions
diff --git a/src/corelib/kernel/qmetatype.h b/src/corelib/kernel/qmetatype.h
index 7f6eaf2230..eacb8403dc 100644
--- a/src/corelib/kernel/qmetatype.h
+++ b/src/corelib/kernel/qmetatype.h
@@ -484,6 +484,7 @@ inline int qMetaTypeId(
+ Q_STATIC_ASSERT_X(QMetaTypeId2<T>::Defined, "Type is not registered, please use Q_DECLARE_METATYPE macro to make it know to Qt's meta-object system");
return QMetaTypeId2<T>::qt_metatype_id();