aboutsummaryrefslogtreecommitdiffstats
path: root/libpyside/pyside.h
diff options
context:
space:
mode:
authorHugo Parente Lima <hugo.lima@openbossa.org>2010-05-20 10:48:59 -0300
committerHugo Parente Lima <hugo.lima@openbossa.org>2010-05-20 11:09:01 -0300
commit34317b147f3c00b0ea81d79219183c1e96bc5533 (patch)
treec36ab42f28b8d94cfd76073c9430cb66e6a7fa2e /libpyside/pyside.h
parentbb32f636589e915811d5ad9dce598f226fa49fbf (diff)
Fix bug#207, Add initQtMetaType class to libpyside.
Reviewer: Renato Araújo <renato.filho@openbossa.org> Luciano Wolf <luciano.wolf@openbossa.org>
Diffstat (limited to 'libpyside/pyside.h')
-rw-r--r--libpyside/pyside.h22
1 files changed, 22 insertions, 0 deletions
diff --git a/libpyside/pyside.h b/libpyside/pyside.h
index 3c1c0600c..2048265f4 100644
--- a/libpyside/pyside.h
+++ b/libpyside/pyside.h
@@ -37,12 +37,34 @@
#include <Python.h>
#include <pysidemacros.h>
+#include <QMetaType>
namespace PySide
{
PYSIDE_API void init(PyObject *module);
+/**
+* If the type \p T was registered on Qt meta type system with Q_DECLARE_METATYPE macro, this class will initialize
+* the meta type.
+*
+* Initialize a meta type means register it on Qt meta type system, Qt itself only do this on the first call of
+* qMetaTypeId, and this is exactly what we do to init it. If we don't do that, calls to QMetaType::type("QMatrix2x2")
+* could return zero, causing QVariant to not recognize some C++ types, like QMatrix2x2.
+*/
+template<typename T, bool OK = QMetaTypeId<T>::Defined >
+struct initQtMetaType {
+ initQtMetaType()
+ {
+ qMetaTypeId<T>();
+ }
+};
+
+// Template specialization to do nothing when the type wasn't registered on Qt meta type system.
+template<typename T>
+struct initQtMetaType<T, false> {
+};
+
} //namespace PySide