Dynamic creation of list<transform>
I am attempting to dynamically create a list<Transform> object in javascript in order to set a transform property.
This is the minimum compilable example I know how to make at the moment.
Code:
import QtQuick 2.5
import QtQuick.Controls 1.4
ApplicationWindow {
visible: true
width: 640
height: 480
Component.onCompleted: {
console.log("Trying to create a transform list");
var newObject = Qt.createQmlObject(
'import QtQuick 2.5; [ Scale { xScale: 1; yScale: 1 } ]',
this,
'newObject');
}
}
It gives the error...
Code:
qrc:/main.qml:12: Error: Qt.createQmlObject(): failed to create object:
qrc:/newObject:1:29: Expected token `,'
qrc:/newObject:1:40: Expected token `}'
Where am I stuck?
At some point, I'm going to need to append to this list, preferably in QML context and not javascript.
Is the following going to work? Will this nest a list in a list or will it extend the original list?
Code:
transform: [ existingTransformList, Translate { x: 5, y: 5} ]
Re: Dynamic creation of list<transform>
Quote:
Originally Posted by
Mookie
Where am I stuck?
The string you pass to createQmlObject() doesn't look like it is valid QML.
Especially the [] brackets seem off, the only valid "top level" tokens are imports and a single Element type.
Have you tried putting it into a separate QML file and load it with qmlscene?
Quote:
Originally Posted by
Mookie
Is the following going to work? Will this nest a list in a list or will it extend the original list?
That looks to me like creating a list that has two values.
If "existingTransformList" is a list itself, then the two type are probably not compatible.
Cheers,
_