How to deal with the hover and press state of custom button?
Unsolved
QML and Qt Quick
-
I'm writing a custom button, the code is shown below
Rectangle { id: control color: "white" states: [ State { name: "hover" when: ma.containsMouse PropertyChanges { control.color: "blue" } }, State { name: "press" when: ma.containsPress PropertyChanges { control.color: "red" } }] transitions: [ Transition { // from: <default state> to: "hover ColorAnimation{ /* some special settings */ } }, Transition { from: "hover" to: "press" ColorAnimation{ /*other special settings */ } }, // other Transitions ] MouseArea { id: ma hoverEnabled: true } }
As you can see here, I want to customize the state trainsition among
default
,hover
andpress
. However, I have no clue to deal with these states. You might advise me to create a new state calleddefault
. However, the color ofcontrol
might be changed by user, that is, I cannot do likeState { name: "default" PropertyChanges { control.color: constrol.color // ???? } }
Anyone can help?