'geometric operations on QML `point` type
Consider a variable of type point: it doesn't seem to have the same methods as vector2d.
E.g.:
readonly property point distance: pos.minus(referencePos).length()
and also there are no conversion functions from point to vector2d.
This does not work:
Qt.vector2d(pos)
Error: Qt.vector2d(): Invalid arguments
So for a typical geometrical operation on points one has to do:
readonly property point distance: Qt.vector2d(pos.x, pos.y).minus(Qt.vector2d(referencePos.x, referencePos.y)).length()
in my opinion exceedingly long and repetitive. I would end up making a library of functions to cut the noise to minimum.
Or am I missing something?
So what's the recommended pattern? Expose properties as point and internally convert to vector2d?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
