import QtQuick 1.0
Rectangle {
id: container
property variant text
signal clicked
height: text.height + 25; width: text.width + 20;
border.width: 7
radius: 100
smooth: true
gradient: Gradient {
GradientStop {
position: 0.0
color: !mouseArea.pressed ? activePalette.light : activePalette.button //this
}
GradientStop {
position: 1.0
color: !mouseArea.pressed ? activePalette.button : activePalette.dark //this
}
}
SystemPalette { id: activePalette }
Text {
id: text
x: 0
y: 0
text: container.text
anchors.verticalCenter: parent.verticalCenter
anchors.horizontalCenter: parent.horizontalCenter
wrapMode: Text.WordWrap
opacity: 1
smooth: true
horizontalAlignment: Text.AlignRight
verticalAlignment: Text.AlignVCenter
style: Text.Outline
font.bold: true
font.pointSize: 35
}
MouseArea {
id: mouseArea
anchors.fill: parent
onClicked: container.clicked()
}
}
import QtQuick 1.0
Rectangle {
id: container
property variant text
signal clicked
height: text.height + 25; width: text.width + 20;
border.width: 7
radius: 100
smooth: true
gradient: Gradient {
GradientStop {
position: 0.0
color: !mouseArea.pressed ? activePalette.light : activePalette.button //this
}
GradientStop {
position: 1.0
color: !mouseArea.pressed ? activePalette.button : activePalette.dark //this
}
}
SystemPalette { id: activePalette }
Text {
id: text
x: 0
y: 0
text: container.text
anchors.verticalCenter: parent.verticalCenter
anchors.horizontalCenter: parent.horizontalCenter
wrapMode: Text.WordWrap
opacity: 1
smooth: true
horizontalAlignment: Text.AlignRight
verticalAlignment: Text.AlignVCenter
style: Text.Outline
font.bold: true
font.pointSize: 35
}
MouseArea {
id: mouseArea
anchors.fill: parent
onClicked: container.clicked()
}
}
To copy to clipboard, switch view to plain text mode
Now, i want to use Keys.onEnterPressed event to trigger the button instead of use mouse clicked event.
But when i attemp to replace mouseArea.pressed with Keys.onEnterPressed , start debugging program, in mainwindow.qml form, when i focus on particular button and i press Enter, the button doesn't seem to be trigger . It has no thing to be pop up in console.log() window .
Anybody can help me, i'm very faithful for you help
Bookmarks