From a1898f4466518bf3e1b6e9154eec05ecf9d909e3 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Sun, 8 Sep 2013 12:08:22 +0200 Subject: Metatype: Remove the need for runtime-registration of 3rd party containers. Replace that need with a macro so that registration of the container helper conversions is done at the time of registration of the container (usually when it is put into a QVariant). Change-Id: I823fb3fdbce306ebc9f146675ac43724cec678d5 Reviewed-by: Olivier Goffart --- .../snippets/code/src_corelib_kernel_qmetatype.cpp | 31 ++++++++++++++++++++++ 1 file changed, 31 insertions(+) (limited to 'src/corelib/doc/snippets/code/src_corelib_kernel_qmetatype.cpp') diff --git a/src/corelib/doc/snippets/code/src_corelib_kernel_qmetatype.cpp b/src/corelib/doc/snippets/code/src_corelib_kernel_qmetatype.cpp index 4437313f0a..cb1346f74c 100644 --- a/src/corelib/doc/snippets/code/src_corelib_kernel_qmetatype.cpp +++ b/src/corelib/doc/snippets/code/src_corelib_kernel_qmetatype.cpp @@ -112,3 +112,34 @@ id = qMetaTypeId(); // compile error if MyStruct not declared typedef QString CustomString; qRegisterMetaType("CustomString"); //! [9] + +//! [10] + +#include + +Q_DECLARE_SEQUENTIAL_CONTAINER_METATYPE(std::deque) + +void someFunc() +{ + std::deque container; + QVariant var = QVariant::fromValue(container); + // ... +} + +//! [10] + +//! [11] + +#include + +Q_DECLARE_ASSOCIATIVE_CONTAINER_METATYPE(std::unordered_map) + +void someFunc() +{ + std::unordered_map container; + QVariant var = QVariant::fromValue(container); + // ... +} + +//! [11] + -- cgit v1.2.3