diff options
Diffstat (limited to 'examples/quick/tutorials/gettingStartedQml/core/Button.qml')
-rw-r--r-- | examples/quick/tutorials/gettingStartedQml/core/Button.qml | 54 |
1 files changed, 27 insertions, 27 deletions
diff --git a/examples/quick/tutorials/gettingStartedQml/core/Button.qml b/examples/quick/tutorials/gettingStartedQml/core/Button.qml index 43383021c9..35a0a618a9 100644 --- a/examples/quick/tutorials/gettingStartedQml/core/Button.qml +++ b/examples/quick/tutorials/gettingStartedQml/core/Button.qml @@ -38,71 +38,71 @@ ** ****************************************************************************/ - import QtQuick 2.0 Rectangle { - //identifier of the item + // Identifier of the item id: button - //these properties act as constants, useable outside this QML file + // These properties act as constants, useable outside this QML file property int buttonHeight: 75 property int buttonWidth: 150 - //attaches to the Text element's text content + // Attaches to the Text element's text content property string label property color textColor: buttonLabel.color - //the color highlight when the mouse hovers on the rectangle + // The color highlight when the mouse hovers on the rectangle property color onHoverColor: "lightsteelblue" property color borderColor: "transparent" - //buttonColor is set to the button's main color + // buttonColor is set to the button's main color property color buttonColor: "lightblue" property real labelSize: 14 - - //set appearance properties + // Set appearance properties radius: 6 antialiasing: true - border { width: 2; color: borderColor } - width: buttonWidth; height: buttonHeight + border.width: 2 + border.color: borderColor + width: buttonWidth + height: buttonHeight Text { id: buttonLabel anchors.centerIn: parent - text: label //bind the text to the parent's text + text: label // Bind the text to the parent's text color: "#DCDCCC" font.pointSize: labelSize } - //buttonClick() is callable and a signal handler, onButtonClick is automatically created + // buttonClick() is callable and a signal handler, + // onButtonClick is automatically created signal buttonClick() - //define the clickable area to be the whole rectangle - MouseArea { + // Define the clickable area to be the whole rectangle + MouseArea { id: buttonMouseArea - anchors.fill: parent //stretch the area to the parent's dimension + anchors.fill: parent // Stretch the area to the parent's dimension onClicked: buttonClick() - //if true, then onEntered and onExited called if mouse hovers in the mouse area - //if false, a button must be clicked to detect the mouse hover + // If true, then onEntered and onExited called if mouse hovers in the mouse area + // If false, a button must be clicked to detect the mouse hover hoverEnabled: true - //display a border if the mouse hovers on the button mouse area + // Display a border if the mouse hovers on the button mouse area onEntered: parent.border.color = onHoverColor - //remove the border if the mouse exits the button mouse area + //Remove the border if the mouse exits the button mouse area onExited: parent.border.color = borderColor } - //change the color of the button when pressed + // Change the color of the button when pressed color: buttonMouseArea.pressed ? Qt.darker(buttonColor, 1.5) : buttonColor - //animate the color whenever the color property changes - Behavior on color { ColorAnimation{ duration: 55 } } - - //scale the button when pressed - scale: buttonMouseArea.pressed ? 1.1 : 1.00 - //Animate the scale property change - Behavior on scale { NumberAnimation{ duration: 55 } } + // Animate the color whenever the color property changes + Behavior on color { ColorAnimation { duration: 55 } } + // Scale the button when pressed + scale: buttonMouseArea.pressed ? 1.1 : 1.0 + // Animate the scale property change + Behavior on scale { NumberAnimation { duration: 55 } } } |