import QtQuick
import QtQuick.Window
import QtQuick.Controls
Window {
id: win
width: 890
height: 500
visible: true
Image {
id: img
source: "qrc:/marrychrismas.jpeg"
fillMode: Image.PreserveAspectFit
}
Component {
id: snowCom
Image {
id: sonw
source: "qrc:/snow.png"
width: 50
height: 50
x: Math.random()*win.width
y: -sonw.height
NumberAnimation on y{
id: anim
loops: Animation.Infinite
from: -sonw.height
to: win.height
duration: 5000
easing.type: Easing.InOutQuad
running: false
}
Timer {
interval: Math.random()*10000
repeat: false
running: true
onTriggered: {
anim.running = true
}
}
}
}
Repeater {
model: 50
delegate: Component {
Loader {
property int modelIndex: index
sourceComponent: snowCom
}
}
}
}
【QML】动画模拟下雪
2023-12-17 16:46:06 57 阅读