Dynamically Construct Path and PathLines
-
Hi,
I'm trying to extend my code to refactor QtQuick 1.1 qml using a repeater or timer onTriggered JS. My ugly code (working), with 24 PathLine elements,
Item {
property Path myPath: Path {
PathLine {x: 0; y: 0}
PathLine {x: 1; y: 0}
PathLine {x: 2; y: 0}
...
PathLine {x: 23; y: 0}
}
}I've tried variations on Repeater/Model.... without success. Usually QT returns 'can't assign object to list'.
Is there a way through code to initialize the Path with 'n' number of PathLines. Any help would be most appreciated.
Thank you -
Hi,
I'm trying to extend my code to refactor QtQuick 1.1 qml using a repeater or timer onTriggered JS. My ugly code (working), with 24 PathLine elements,
Item {
property Path myPath: Path {
PathLine {x: 0; y: 0}
PathLine {x: 1; y: 0}
PathLine {x: 2; y: 0}
...
PathLine {x: 23; y: 0}
}
}I've tried variations on Repeater/Model.... without success. Usually QT returns 'can't assign object to list'.
Is there a way through code to initialize the Path with 'n' number of PathLines. Any help would be most appreciated.
Thank you -
Hi,
I'm trying to extend my code to refactor QtQuick 1.1 qml using a repeater or timer onTriggered JS. My ugly code (working), with 24 PathLine elements,
Item {
property Path myPath: Path {
PathLine {x: 0; y: 0}
PathLine {x: 1; y: 0}
PathLine {x: 2; y: 0}
...
PathLine {x: 23; y: 0}
}
}I've tried variations on Repeater/Model.... without success. Usually QT returns 'can't assign object to list'.
Is there a way through code to initialize the Path with 'n' number of PathLines. Any help would be most appreciated.
Thank you -
I have the Path and PathLine working with the above initial declaration of Path and Pathline. What I've been trying to do is either user a timer OnTriggered to create the Path and append/push... pathElements, or, use a Repeater to create the path. Variations on things I've tried below.
a) Timer OnTriggered,
var pathLine = Qt.createQmlObject('import QtQuick 1.1;PathLine {x:0; y:0}',_myPath) if(_myPath.pathElements.length == 0) { for(var j=0;j<24;j++) { _myPath.pathElements.push({"x":j,"y":0}) } }b) Repeater,
Repeater{ id: repeater model: myModel delegate: Item{ property ShapePath s: ShapePath{ strokeWidth: 2 PathLine{x: model.x; y: model.y} } Component.onCompleted: { shape.data.push(s) } } } }My line chart is 48 segments and is fine for what I'm trying to do. The code is not very elegant, but works. Thanks