我正在寻找一种用QML为按钮的所有状态创建自定义样式的方法。到目前为止,我只发现了以下可以应用于多个按钮的样式创建方式。
Component {
id: leftButtonStyle
ButtonStyle {
background: Rectangle {
width: control.width
height: control.height
color: "black"
}
label: Text {
font.family: "Helvetica"
font.pointSize: 10
color: "#949599"
text: control.text
}
}
}
Button {
text:"Button One"
style: leftButtonStyle
}
Button {
text:"Button Two"
style: leftButtonStyle
}
但这只是改变了按钮的普通状态,找不到一种在按钮被按下时给予样式的方法。