From 546d52e605b6a74d9a5be26fb374b831a46f2550 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Sun, 8 Sep 2013 08:49:29 +0200 Subject: Add a convenient way to get a type-erased smart pointer from a QVariant. Any known smart pointer in a QVariant can be handled in this way. The metatype system can be informed of new smart pointer types using an existing macro which is now documented. This is very similar to the existing infrastructure for containers. Change-Id: Iac4f9fabbc5a0626c04e1185d51d720b8b54603d Reviewed-by: Olivier Goffart --- src/corelib/kernel/qmetatype.cpp | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'src/corelib/kernel/qmetatype.cpp') diff --git a/src/corelib/kernel/qmetatype.cpp b/src/corelib/kernel/qmetatype.cpp index 2ab6681bb9..70c2e236dd 100644 --- a/src/corelib/kernel/qmetatype.cpp +++ b/src/corelib/kernel/qmetatype.cpp @@ -174,6 +174,22 @@ struct DefinedTypesFilter { \snippet code/src_corelib_kernel_qmetatype.cpp 11 */ +/*! + \macro Q_DECLARE_SMART_POINTER_METATYPE(SmartPointer) + \relates QMetaType + + This macro makes the smart pointer \a SmartPointer known to QMetaType as a + smart pointer. This makes it possible to put an instance of SmartPointer into + a QVariant, if T is a type which inherits QObject. + + Note that the QWeakPointer, QSharedPointer and QPointer already have built-in + support, and it is not necessary to use this macro with them. + + This example shows a typical use of Q_DECLARE_SMART_POINTER_METATYPE(): + + \snippet code/src_corelib_kernel_qmetatype.cpp 13 +*/ + /*! \enum QMetaType::Type -- cgit v1.2.3