QtJsonSerializer
QtJsonSerializer copied to clipboard
registerSetConverters results in build time error no matching function to call qHash(...
registerSetConverters results in build time error no matching function to call qHash(... my class
class simpleGadget
{
Q_GADGET
Q_PROPERTY(int id MEMBER id)
Q_PROPERTY(bool flag MEMBER flag);
Q_PROPERTY(float fValue MEMBER fValue);
Q_PROPERTY(double dValue MEMBER dValue);
Q_PROPERTY(long lValue MEMBER lValue);
Q_PROPERTY(QString sValue MEMBER sValue);
Q_PROPERTY(QList<int> iValues MEMBER iValues);
Q_PROPERTY(QByteArray byteValue MEMBER byteValue);
public:
simpleGadget(){}
~simpleGadget(){}
int id = -1;
bool flag = true;
float fValue = 3.14;
double dValue = 33.5555555;
long lValue = 100000;
QByteArray byteValue = "1234567A";
QString sValue = "Hello World";
QList<int> iValues = {1,2,3};
QByteArray expectedJson = "{\"byteValue\":\"MTIzNDU2N0E=\",\"dValue\":33.5555555,\"fValue\":3.140000104904175,\"flag\":true,\"iValues\":[1,2,3],\"id\":-1,\"lValue\":\"100000\",\"sValue\":\"Hello World\"}";
bool operator==(const simpleGadget& newValue) const
{
return (id == newValue.id &&
flag == newValue.flag &&
fValue == newValue.fValue &&
dValue == newValue.dValue &&
lValue == newValue.lValue &&
sValue == newValue.sValue &&
iValues == newValue.iValues &&
byteValue == newValue.byteValue);
}
bool operator!=(const simpleGadget& newValue) const
{
return !(*this == newValue);
}
};
Q_DECLARE_METATYPE(simpleGadget)