summaryrefslogtreecommitdiffstats
path: root/src/corelib/kernel/qobject.h
diff options
context:
space:
mode:
authorAaron Kennedy <aaron.kennedy@nokia.com>2009-07-30 00:52:40 (GMT)
committerAaron Kennedy <aaron.kennedy@nokia.com>2009-07-31 01:18:57 (GMT)
commit46ca473d569b92cdfc567c2096b1c4af3ba68f80 (patch)
tree8473ac40544084f0e6e18876c3605ea2603ef6c8 /src/corelib/kernel/qobject.h
parent87239ef6438b50b2dfa7b6526a5e5cbe7d5598d5 (diff)
downloadQt-46ca473d569b92cdfc567c2096b1c4af3ba68f80.zip
Qt-46ca473d569b92cdfc567c2096b1c4af3ba68f80.tar.gz
Qt-46ca473d569b92cdfc567c2096b1c4af3ba68f80.tar.bz2
Allow retrieval of interface IId from class type.
This method is necessary for QML to support Qt interfaces, but probably shouldn't be used otherwise. Reviewed-by: Roberto Raggi
Diffstat (limited to 'src/corelib/kernel/qobject.h')
-rw-r--r--src/corelib/kernel/qobject.h10
1 files changed, 10 insertions, 0 deletions
diff --git a/src/corelib/kernel/qobject.h b/src/corelib/kernel/qobject.h
index 1fb216b..4715626 100644
--- a/src/corelib/kernel/qobject.h
+++ b/src/corelib/kernel/qobject.h
@@ -379,6 +379,9 @@ inline QList<T> qFindChildren(const QObject *o, const QRegExp &re)
#endif // Q_MOC_RUN
+template <class T> inline const char * qobject_interface_iid()
+{ return 0; }
+
template <class T> inline T qobject_cast_helper(QObject *object, T)
{ return static_cast<T>(((T)0)->staticMetaObject.cast(object)); }
@@ -395,6 +398,8 @@ inline T qobject_cast(const QObject *object)
#ifndef Q_MOC_RUN
# define Q_DECLARE_INTERFACE(IFace, IId) \
+ template <> inline const char *qobject_interface_iid<IFace *>() \
+ { return IId; } \
template <> inline IFace *qobject_cast_helper<IFace *>(QObject *object, IFace *) \
{ return (IFace *)(object ? object->qt_metacast(IId) : 0); } \
template <> inline IFace *qobject_cast_helper<IFace *>(const QObject *object, IFace *) \
@@ -458,8 +463,13 @@ inline T qobject_cast(const QObject *object)
}
+template <class T> inline const char * qobject_interface_iid()
+{ return 0; }
+
#ifndef Q_MOC_RUN
# define Q_DECLARE_INTERFACE(IFace, IId) \
+ template <> inline const char *qobject_interface_iid<IFace *>() \
+ { return IId; } \
template <> inline IFace *qobject_cast<IFace *>(QObject *object) \
{ return reinterpret_cast<IFace *>((object ? object->qt_metacast(IId) : 0)); } \
template <> inline IFace *qobject_cast<IFace *>(const QObject *object) \