Hi,
I'm trying to make a small paint application with QML/Felgo, but I'm having problems adding paint strokes to the Path object. I tried adding the newly created newPathElement to myPath.pathElements in different ways, but nothing seems to work. How can I achieve this?
Thanks!
Canvas {
width: 400; height: 200
contextType: "2d"
Path {
id: myPath
startX: 0; startY: 100
}
onPaint: {
context.strokeStyle = Qt.rgba(.4,.6,.8);
context.fillStyle = Qt.rgba(1.0, 1.0, 1.0, 1.0);
context.lineWidth = 5.0;
context.path = myPath;
context.stroke();
}
MouseArea {
anchors.fill: parent
property string sc: 'import QtQuick 2.0; PathCurve {}'
onPositionChanged: {
var newPathElement = Qt.createQmlObject(sc, myPath, "curve");
newPathElement.x = mouse.x;
newPathElement.y = mouse.y;
// ???????????????? myPath.pathElements.push() doesn't work...
}
}
}