1. 编辑main.qml
import QtQuick
import QtQuick.Particles
Window {
width: 800
height: 800
visible: true
title: qsTr("Hello World")
color: "#000000"
MouseArea {
id: mouseArea
anchors.fill: parent
onClicked: {
hahaEmitter.pulse(2000)
}
}
ParticleSystem { id: hahaParticleSystem }
ImageParticle {
system: hahaParticleSystem
source: "qrc:/Resources/Images/ha.png"
width: 100
height: 100
}
//! [0]
Emitter {
id: hahaEmitter
system: hahaParticleSystem
emitRate: 10
lifeSpan: 10000
enabled: false
y: mouseArea.mouseY
x: mouseArea.mouseX
velocity: PointDirection {x: 0; y: -1;}
acceleration: PointDirection {x: 0; y: -10;}
size: 50
sizeVariation: 25
}
}
2. 运行程序