Class used to convert QObject into QVariant and vivce-versa. During these operations only the class attributes defined as properties will be considered. Properties marked as 'non-stored' will be ignored. More...
#include <qobjecthelper.h>
Static Public Member Functions | |
static QVariantMap | qobject2qvariant (const QObject *object, const QStringList &ignoredProperties=QStringList(QString(QLatin1String("objectName")))) |
static void | qvariant2qobject (const QVariantMap &variant, QObject *object) |
Class used to convert QObject into QVariant and vivce-versa. During these operations only the class attributes defined as properties will be considered. Properties marked as 'non-stored' will be ignored.
Suppose the declaration of the Person class looks like this:
The following code will serialize an instance of Person to JSON :
The generated output will be:
It's also possible to initialize a QObject using the values stored inside of a QVariantMap.
Suppose you have the following JSON data stored into a QString:
The following code will initialize an already allocated instance of Person using the JSON values:
Definition at line 116 of file qobjecthelper.h.
|
static |
This method converts a QObject instance into a QVariantMap.
object | The QObject instance to be converted. |
ignoredProperties | Properties that won't be converted. |
Definition at line 44 of file qobjecthelper.cpp.
|
static |
This method converts a QVariantMap instance into a QObject
variant | Attributes to assign to the object. |
object | The QObject instance to update. |
Definition at line 63 of file qobjecthelper.cpp.
hosts this site. |
Send comments to: QJson Developers |