@tansgumus said in Button backgound non-existent property!:
Component.onCompleted: {
// WORKS!
// button.background.color = "red"
// WRONG
background = Rectangle { color: "red" }
}
Because Component.onCompleted is a javascript function and you can use only js syntax inside it. Rectangle { color: "red" } is QML specific syntax, js doesn't understand it. You can create a component dynamically (see the QML docs) by giving the component as a string to Qt.createQmlObject().
If you use button.background.color = "red" in Component.onCompleted it retains all other properties of the backround; I have found it to be a convenient way to change only one or two properties without messing others. Using other approaches, i.e. defining the whole component either dynamically or declaratively, overwrites everything which may or may not be desirable.