my question is very simple. If i have created a qml component dynamically , how can i set its properties ?
In this my example i want to change the color when i click on button element
Window {
id:win
visible: true
width: 640
height: 480
title: qsTr("Hello World")
Component.onCompleted: {
var comp=Qt.createComponent("MyRectangle.qml")
comp.createObject(page,{"id":"pippo","color":"yellow","width":50})
}
Page{
id: page
anchors.fill: parent
Button{
x:200
height: 50
width: 50
onClicked:{
// i want to set color of the rectangle tha i have created
}
}
}
}
MyRectangle is a my custom qml object.
Rectangle {
id:pippo
color:"red"
width:30
height: 30
}