-
import QtQuick 2.12
: Imports version 2.12 of the QtQuick module, used to create user interfaces for Qt Quick applications.
-
import QtQuick.Window 2.12
: Imports version 2.12 of the QtQuick.Window module, used to create window objects.
-
import QtQuick.Controls 2.12
: Imports version 2.12 of the QtQuick.Controls module, used to create user interface controls.
-
Window {}
: Define a window object, and set the properties and components of the window within the curly braces.
-
id: window
: Sets a unique identifier for the window object.
-
visible: true
: Set the window object to be visible.
-
width: 600
: Sets the width of the window to 600 units.
-
height: 600
: Sets the height of the window to 600 units.
-
title: qsTr("QML study")
: Set the title of the window to "QML study", and use the qsTr function for translation.
-
Image {}
: A picture object is defined, and the properties and components of the picture are set within the curly braces.
-
id: root
: Sets a unique identifier for the image object.
-
source: "pic//C.png"
: Set the source of the picture as "pic//C.png".
-
anchors.fill: parent
: Set the image object to fill the parent container.
-
property int padding: 10
: An attribute variable padding is defined and its value is set to 10.
-
property int duration: 3000
: An attribute variable duration is defined and its value is set to 3000.
-
property bool running: false
: An attribute variable running is defined and its value is set to false.
-
Image {}
: Another picture object is defined inside the picture object, and its properties and components are set.
-
id: box
: Sets a unique identifier for the internal image object.
-
x: root.padding
: Set the x coordinate of the internal image object to the value of root.padding.
-
y: (root.height - height) / 2
: Set the y coordinate of the internal image object to a value of (root.height - height) / 2.
-
source: "pic//5.jpg"
: Set the source of the internal picture as "pic//5.jpg".
-
sourceSize: Qt.size(200,200)
: Set the display size of the internal image to 200x200 pixels.
-
NumberAnimation on x {}
: Creates a numerical animation of the x property, and sets the animated property and value within curly braces.
-
to: root.width - box.width - root.padding
: Set the target value of the animation to the value of (root.width - box.width - root.padding).
-
duration: root.duration
: Set the duration of the animation to the value of root.duration.
-
running: root.running
: Set the state of whether the animation is running to the value of root.running.
-
RotationAnimation on rotation {}
: Create a rotation animation for the rotation property, and set the properties and values of the animation within the curly braces.
-
to:360
: Set the target value of the rotation animation to 360 degrees.
-
duration: root.duration
: Set the duration of the rotation animation to the value of root.duration.
-
running: root.running
: Set the status of whether the rotation animation is running to the value of root.running.
-
MouseArea {}
: Define a mouse region object, and set the properties and events of the region within the curly braces.
-
anchors.fill: parent
: Set the mouse area object to fill the parent container.
-
onClicked: root.running = true
: When the mouse area is clicked, set the root.running property to true.
-
ClickableImageV2 {}
: Defines a clickable image object, and sets the attributes and components of the image within curly braces.
-
id: greenBox
: Sets a unique identifier for clickable image objects.
-
x: 40
, y: root.height-height
: Set the initial values of the x and y coordinates of the clickable image object.
-
source: "pic//1.jpg"
: Set the source of the clickable picture to "pic//1.jpg".
-
text: qsTr("animation on property")
: Set the text of the clickable image to "animation on property", and use the qsTr function for translation.
-
NumberAnimation on y {}
: Creates a numerical animation of the y property, and sets the animated property and value within curly braces.
-
to: 40
: Sets the animation's target value to 40.
-
duration:3000
: Sets the duration of the animation to 3000.
-
running: root.running
: Set the state of whether the animation is running to the value of root.running.
-
Behavior on y {}
: Use the Behavior element inside the clickable image object to control how the properties are animated.
-
NumberAnimation { duration: 3000 }
: The numerical animation of the attribute is set, and the duration of the animation is set to 3000.
-
onClicked: y = 40 + Math.random() * (205-40)
: When the clickable image object is clicked, set the y property to a random value between 40 and 205.
-
ClickableImageV2 {}
: Define another clickable image object, and set the properties and components of the image within the curly braces.
-
id: redBox
: Sets a unique identifier for clickable image objects.
-
x: root.width-width-40
, y: root.height-height
: Set the initial values of the x and y coordinates of the clickable image object.
-
source: "pic//3.jpg"
: Set the source of the clickable picture to "pic//3.jpg".
-
onClicked: anim.start()
: When the clickable image object is clicked, the anim animation is triggered to start playing.
-
text: qsTr("standalone animation")
: Set the text of the clickable image to "standalone animation", and use the qsTr function for translation.
-
NumberAnimation {}
: Defines a numerical animation to control the numerical change of the attribute.
-
target: redBox
: The target object of the animation is redBox, that is, the object whose properties are to be changed.
-
properties: "y"
: Set the property to be changed by animation as y.
-
to: 40
: Sets the animation's target value to 40.
-
duration: 3000
: Sets the duration of the animation to 3000.
-
import QtQuick 2.0
: Imports version 2.0 of the QtQuick module, used to create user interfaces for Qt Quick applications.
-
Item {}
: Defines a clickable item, and sets the properties and components of the item within the curly braces.
-
id:root
: Sets a unique identifier for the item.
-
width: column.childrenRect.width
: Set the width of the item to the width of the column (Column) sub-element.
-
height: column.childrenRect.height
: Set the height of the item to the height of the column (Column) sub-element.
-
property alias text: label.text
: Defines an attribute named text and associates it with the text attribute of label, allowing the attribute to be accessed and modified externally.
-
property alias source: image.source
: Defines an attribute named source and associates it with the source attribute of image, allowing external access and modification of the attribute.
-
signal clicked
: Declare a clicked signal, indicating the event that the item is clicked.
-
Column {}
: defines a column (Column), used to organize the vertical arrangement of sub-elements.
-
id:column
: Sets a unique identifier for the column.
-
spacing: 10
: Sets the spacing between child elements in the column to 10 units.
-
Image {}
: A picture object is defined, and the properties and components of the picture are set within the curly braces.
-
id: image
: Sets a unique identifier for the image object.
-
sourceSize: Qt.size(90,90)
: Set the display size of the image to 90x90 pixels.
-
Text {}
: Define a text object, and set the properties and components of the text within the curly braces.
-
id: label
: Sets a unique identifier for the text object.
-
width: image.width
: Set the width of the text to be the same as the width of the image.
-
horizontalAlignment: Text.AlignHCenter
: Set the horizontal alignment of the text to center alignment.
-
wrapMode: Text.WordWrap
: Set the line wrapping mode of the text to automatic line wrapping.
-
color: "#000000"
: Set the color of the text to black.
-
MouseArea {}
: Define a mouse region object, and set the properties and events of the region within the curly braces.
-
anchors.fill: parent
: Set the size of the mouse area to be the same as the parent element (Item), filling the entire area.
-
onClicked: root.clicked()
: When the mouse area is clicked, the clicked signal of the item is triggered.