I have the following problem.
I am developing a model in C++ and a View in Qml, connecting them via Controllers. In my model I perform multiple calculations. I also offer users of my application the possibility, to write custom event handlers, written in qml. Now I came across a point, where I decided to use Fixed point notation and I have written a corresponding C++ class. Now I want offer the FixedPoint class - including all its operators - to developers, who decide to extend my application in Qml. So far, I offered all data as QProperties, which is required by coding guidelines. But I am open for other solutions to discuss them in my team. Clearly, a fixed point is no identity and algorithms rely on the possibility of copying it, which is not allowed when inheriting from QObject.
So the question arrives: How can I expose a c++ class / struct to QML, which is NOT an identity?
An example in code:
struct FixedPoint
{
FixedPoint(FixedPoint&);
FixedPoint& operator=(FixedPoint&);
...
int mantissa;
int exponent;
}
I want to use it in Qml as an property (value) of a QQuickItem written in C++:
MyQmlObject{
value{ mantissa: 134; exponent: 3 }
}
The property value is then used throughout computations in javascript and is copied several times a long the way. So I cannot make value a property of type FixedPoint* I think. Am I right?