controls
import QtQuick 2.7
import QtQuick.Controls 1.4
import QtQuick.Controls.Styles 1.4
Rectangle {
color: "green"
Button {
id:button
text: qsTr("Second page")
anchors.centerIn: parent
property string url: "qrc:/bg.png"
style: ButtonStyle {
id:button_style
background: Image {
id: button_image
source: button.url
}
}
MouseArea{
anchors.fill: parent
onPressed: {
parent.state = "focus"
}
onExited: parent.state = "namol"
}
states: [
State {
name: "focus"
PropertyChanges {
target: button
url:"qrc:/on.png"
}
},
State {
name: "namol"
PropertyChanges {
target: button
url:"qrc:/bg.png"
}
}
]
}
}
controls2
import QtQuick 2.7
import QtQuick.Controls 2.0
Rectangle {
color: "green"
Button {
id:button
text: qsTr("Second page")
anchors.centerIn: parent
property string url: "qrc:/bg.png"
contentItem: Text {
text: button.text
font: button.font
color: "black"
horizontalAlignment: Text.AlignHCenter
verticalAlignment: Text.AlignVCenter
elide: Text.ElideRight
}
background: Image {
id: button_image
source: button.url
}
MouseArea{
anchors.fill: parent
onPressed: {
parent.state = "focus"
}
onExited: parent.state = "namol"
}
states: [
State {
name: "focus"
PropertyChanges {
target: button
url:"qrc:/on.png"
}
},
State {
name: "namol"
PropertyChanges {
target: button
url:"qrc:/bg.png"
}
}
]
}
}