classPiiQVariantWrapper
#include <PiiQVariantWrapper.h>
A serialization wrapper for user types in QVariants.
Inherited by PiiQVariantWrapper::Template< T >
Description
To enable serialization of a user type as a QVariant, one needs to subclass PiiQVariantWrapper. The subclass must be registered as a serializable object with the standard template serializer naming syntax, e.g. "PiiQVariantWrapper<MyType>". The serializer needs to store and retrieve "MyType" and store it as the value of the internal #_variant member.
// In MyClass.h first declare the type as a Qt meta type: extern int iMyClassTypeId; Q_DECLARE_METATYPE(MyClass); // In MyClass.cc register the meta type: int iMyClassTypeId = qRegisterMetaType<MyClass>("MyClass"); // Then register the wrapper as a serializable object: #include <PiiQVariantWrapper.h> #define PII_SERIALIZABLE_CLASS PiiQVariantWrapper::Template<MyClass> #define PII_SERIALIZABLE_CLASS_NAME "PiiQVariantWrapper<MyClass>" #include <PiiSerializableRegistration.h>
Classes
| class |
A template that is instantiated for all user types intended to be serialized as QVariants. |
Constructors and destructor
|
virtual
|
Public member functions
|
void
|
Set the variant to |
|
( )
Get a reference to the variant. |
Friends
|
friend struct
|
|
Function details
-
virtual ~PiiQVariantWrapper
()[virtual] -
template<class Archive>
void serialize
(- Archive &
- const unsigned int
[inline] -
Set the variant to
v, which stores a user type.After calling this function, subclass can store the actual user type.
-
Get a reference to the variant.
Subclasses store the actual user type into the protected #_variant member variable. Use this function to retrieve the restored value.
Add a note
Not a single note added yet. Be the first, add yours.