Hi forum readers !
I have been trying to change my parent value in QML without success. Bellow you can find a code example. The goal is to, when the button is pressed, change the item in my Context Menu (from “english” to “good bye”).
To do so i generate a Context Menu out of an array, add an id to the Menu Item and change the Menu Item text properties from the Button. Yet when doing so i get the: QQmlComponent: Component is not ready error..
property var arrayOne: ({})
ComboBox {
property alias comboText:
id: firstComboBox
label: "combo box label"
menu : ContextMenu {
id: firstContextMenu
Repeater {
id: firstRepeater
Component.onCompleted: {
console.log("good morning")
arrayOne = ["hi", "english", "ciao", "italian", "halo", "german"]
}
model: arrayOne
MenuItem {
id: firstMenuItem
text: "%1".arg(modelData[1])
onClicked: console.log(modelData[0])
}
}
}
Button {
text: "change value"
onClicked: firstMenuItem.text = "good bye"
}
If i specify a deeper “path”, such as firstComboBox.firstRepeater.firstMenuItem.text that doesn’t work since Property Aliases cannot refer to properties inside a hierarchy with depth 3 (and i also think the problem isn’t there yet since i get the same erros as when the depth is of 1).
Do you have any suggestion on how to proceed please ?