QML开发——3D旋转特效
程序员文章站
2022-07-13 08:28:38
...
目录
效果动图
:
MyGraph.qml
import QtQuick 2.7
Rectangle{
//设置矩形高度与载入图像相吻合
width: animg.width
height: animg.height
transform: Rotation{
//设置图像原点
origin.x: animg.width/2
origin.y: animg.height/2
axis{
x: 0
y: 1 //设置围绕y轴旋转
z: 0
}
NumberAnimation on angle{ //定义角度上的动画
from: 0
to: 360
duration: 20000
loops: Animation.Infinite
}
}
AnimatedImage{
id:animg
source: "Images/dali.png"
}
}
main.qml
import QtQuick 2.12
import QtQuick.Window 2.12
Window {
visible: true
width: 640
height: 480
title: qsTr("3D效果")
Rectangle{
MouseArea{
id: mouseArea
anchors.fill: parent
}
MyGraph{}
}
}