Skip to content
This repository has been archived by the owner on Mar 4, 2023. It is now read-only.

Sample: SerializationException (Unable to determine typeid of meta enum SampleObject::SuperFlags) #39

Open
samueleforconi opened this issue Jul 31, 2020 · 1 comment
Labels

Comments

@samueleforconi
Copy link

Hi,
I compiled the QtJsonSerializer, and installed.
Then try to run sample, the only change was to Sample.pro where I added CONFIG += c++1z
If I run the Sample application from the command line I get the following output:

Serializing SampleGadget:
{
    "base": [
        42,
        13
    ],
    "rawData": {
        "someData": false
    }
}


And deserializing data back:
base: QPoint(42,13)
rawData: {
    "someData": false
}


Now the test object, with the previous gadget as child:
terminate called after throwing an instance of 'QtJsonSerializer::SerializationException'
  what():  what: Failed to serialize with error: Unable to determine typeid of meta enum SampleObject::SuperFlags
Property Trace:
	flags (Type: SuperFlags)
Annullato (core dump creato)

System is Ubuntu 16.04 with:
Qt v5.14.2
g++ v7.5.0

@Skycoder42 Skycoder42 added the bug label Aug 4, 2020
@bigbangsw
Copy link

bigbangsw commented Jan 1, 2021

Register QMetaType in main.cpp

` auto obj = new SampleObject(qApp);

// Insert Next Line : Register QMetaType
qRegisterMetaType<SampleObject::SuperFlags>("SuperFlags");


obj->id = 10;
obj->title = QStringLiteral("Example");
obj->flags = (SampleObject::SuperFlag)((int)SampleObject::ValueA | (int)SampleObject::ValueB);
obj->scores = {0.0, 6.66, 47.11};
obj->secret = QStringLiteral("Very secret string, not serialized");
obj->gadget = gadget;
json = serializer.serialize(obj);
qDebug() << JSON_PRINT(json);`

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

3 participants