Hi Filippo,

the equivalent to Q_OBJECT for value types is Q_GADGET. So, your data structure would look like this:

struct DataPoint
{
    Q_GADGET
    Q_PROPERTY(double x MEMBER x)
    Q_PROPERTY(double y MEMBER y)

public:
    double x;
    double y;
}

Now, depending on what you want to do with that in JS it may or may not work. I'd need some more details there.

NB: In QML (as opposed to JS) you can register named value types these days. There is the QML_VALUE_TYPE macro. In QML value types can be constructible and/or structured, offering different ways to create them from JS expressions. Finally, in QML, value types can be stored in lists. You can have "property list<dataPoint>" if you use QML for your scripting.

best regards,
Ulf
_______________________________________________
Interest mailing list
Interest@qt-project.org
https://lists.qt-project.org/listinfo/interest

Reply via email to