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.
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');
}
}
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');
}
}
To copy to clipboard, switch view to plain text mode
It gives the error...
qrc:/main.qml:12: Error: Qt.createQmlObject(): failed to create object:
qrc:/newObject:1:29: Expected token `,'
qrc:/newObject:1:40: Expected token `}'
qrc:/main.qml:12: Error: Qt.createQmlObject(): failed to create object:
qrc:/newObject:1:29: Expected token `,'
qrc:/newObject:1:40: Expected token `}'
To copy to clipboard, switch view to plain text mode
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?
transform: [ existingTransformList, Translate { x: 5, y: 5} ]
transform: [ existingTransformList, Translate { x: 5, y: 5} ]
To copy to clipboard, switch view to plain text mode
Bookmarks