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 has been 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)
The text was updated successfully, but these errors were encountered:
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
Sign up for freeto subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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)
public:
Q_INVOKABLE Spectra(QObject *parent = nullptr) : QObject(parent)
{
type = ST_Reflectance;
incidenceAngle = 0.0;
polarization = SP_Unpolarized;
}
};
Q_DECLARE_METATYPE(Spectra *) `
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)
The text was updated successfully, but these errors were encountered: