4
我无法尝试使用Javascript在QML中生成对象以动态创建对象。如何用变量动态创建对象?
我想使用的代码是这样的
Grid {
id: numbers
anchors.centerIn: parent
columns: 3
spacing: 2
function createNumbers(){
var component = Qt.createComponent("Button.qml");
for(var i=1; i<37; i++){
component.createObject(numbers)
}
}
Component.onCompleted: createNumbers()
}
,工作正常,但我想包括变量,使他们每个人不同的,所以,当我将信息传递给Button.qml它集以下
property string text: "1"
property string id: "button1"
我想不出来,任何帮助将是伟大的,谢谢你们。
是的字面上,你输入,我只是想出来,非常感谢:) – Steve