I have an issue with QML PathPolyLine "path" property. In documentation it said that:
It can be a JS array of points constructed with Qt.point()
Does it mean I can work with it like with JS array?
Here is an example that shows that .push() doesn't work for it "path" property, but I can set a custom array and then appoint my custom array to "path" property of PathPolyLine element.
So what is the correct way of editing this property?
Also setting alias to this property like this property alias myArray: PathPolyLineID.path to work with "myArray" not affecting ".path" too.
main.qml
import QtQuick
import QtQuick.Controls
Window {
id: mainWinID
width: 640
height: 480
visible: true
title: qsTr("Hello World")
property var points: []
Button
{
property int i: 0
id: btnID
text: "Click Me!"
onClicked:
{
if (i == 2) pplID.path = mainWinID.points;
pplID.path.push(Qt.point(i,i+10));
mainWinID.points.push(Qt.point(i,i+10));
console.log('pplID.path:', pplID.path);
console.log('mainWinID.points:', mainWinID.points);
i++;
}
}
PathPolyline
{
id: pplID
path: []
}
}
Outcome is such:
qml: pplID.path: []
qml: mainWinID.points: [QPointF(0, 10)]
qml: pplID.path: []
qml: mainWinID.points: [QPointF(0, 10),QPointF(1, 11)]
qml: pplID.path: [QPointF(0, 10),QPointF(1, 11)]
qml: mainWinID.points: [QPointF(0, 10),QPointF(1, 11),QPointF(2, 12)]
qml: pplID.path: [QPointF(0, 10),QPointF(1, 11)]
qml: mainWinID.points: [QPointF(0, 10),QPointF(1, 11),QPointF(2, 12),QPointF(3, 13)]