You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Mar 4, 2023. It is now read-only.
Repository navigation
This repository was archived by the owner on Mar 4, 2023. It is now read-only.
Hi I'm using Qt version 5.10.0.
I get this error when serializing this class :
`class Spectra : public QObject
{
Q_OBJECT
Q_ENUM(SpectrumType)
Q_ENUM(SpectrumPolarization)
Q_PROPERTY(double incidenceAngle MEMBER incidenceAngle)
Q_PROPERTY(SpectrumType type MEMBER type)
Q_PROPERTY(SpectrumPolarization polarization MEMBER polarization)
At runtime it says ;
QMetaProperty::read: Unable to handle unregistered datatype 'SpectrumType' for property 'Spectra::type'
QMetaProperty::read: Unable to handle unregistered datatype 'SpectrumPolarization' for property 'Spectra::polarization'
Then serializes the object as depicted below { "spectraList": [ { "incidenceAngle": 0, "polarization": null, "type": null } ] }
To register datatypes I added required meta type declarations;
Q_DECLARE_METATYPE(SpectrumType) Q_DECLARE_METATYPE(SpectrumPolarization)
This time QtJsonserializer throws exeption and crashes; terminate called after throwing an instance of 'QJsonSerializationException' what(): what: Failed to serialize with error: Failed to convert type SpectrumType to a JSON representation Property Trace: spectraList (Type: QList<Spectra*>) [0] (Type: Spectra*) type (Type: SpectrumType)
I think my version is old because i could not find QtJsonSerializer::JsonSerializer::registerBasicConverters. How can i make sure which version I use? Actually I tried to use Qt maintenance tool to install the lasest version but i seems did not work.
I build the repo manually because I am using Qt 5.15.0 and it's not included as a add on. Just follow his steps for building manually. Just make sure your build output is the same dir as repo because his build process uses generated files that are stored in the repos sub dirs
Activity
pjorourke05 commentedon Feb 27, 2021
if I register my enum with the serializer it will work
wartista commentedon Feb 28, 2021
I think my version is old because i could not find QtJsonSerializer::JsonSerializer::registerBasicConverters. How can i make sure which version I use? Actually I tried to use Qt maintenance tool to install the lasest version but i seems did not work.
pjorourke05 commentedon Mar 1, 2021
I build the repo manually because I am using Qt 5.15.0 and it's not included as a add on. Just follow his steps for building manually. Just make sure your build output is the same dir as repo because his build process uses generated files that are stored in the repos sub dirs