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

registerSetConverters results in build time error no matching function to call qHash(... #46

Open
pjorourke05 opened this issue Mar 3, 2021 · 0 comments

Comments

@pjorourke05
Copy link

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)
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant