Reputation: 305
I need my button to changed gradient when pressed. I've tried the following code (suggested by official documentation):
Button {
background: Rectangle {
gradient: Gradient {
GradientStop { position: 0 ; color: control.pressed ? "#ccc" : "#eee" }
GradientStop { position: 1 ; color: control.pressed ? "#aaa" : "#ccc" }
}
}
}
However, my button turns out black. By substituing the word 'control' with the word 'this' or 'parent', I get the same result: the button is correctly coloured in case it is not pressed, but when I press it, nothing changes.
Upvotes: 0
Views: 1362
Reputation: 49329
You forgot to give your button an id:control
.
this.pressed
and parent.pressed
will be undefined
, which means they will resolve to false
.
Upvotes: 2