import QtQuick 2.7
import QtQuick.Controls 2.0
import QtGraphicalEffects 1.0
Rectangle
{
visible: true
width: 400
height: 300
Text
{
id: textID
height: 240
width: 240
anchors.centerIn: parent
text:"点击鼠标可旋转文字"
verticalAlignment: Text.AlignVCenter
horizontalAlignment: Text.AlignHCenter
font.pointSize: 13
MouseArea
{
anchors.fill: parent
onClicked:
{
if(rotationAnimation.running === true)
return;
rotationAnimation.start();
}
}
LinearGradient
{
source: textID
width: 240
height: 240
gradient: Gradient
{
GradientStop
{
position: 0.0
color: "#22F222"
}
GradientStop
{
position: 0.9
color: "#F0280F"
}
}
start: Qt.point(0,0)
end: Qt.point(240,240)
}
}
RotationAnimation
{
id: rotationAnimation
target: textID
from: currentAngle
to: currentAngle+diff
duration: 100
readonly property int diff: 5
property int currentAngle: 0
property bool isDown: true
onStopped:
{
rotationAnimation.from = rotationAnimation.to
rotationAnimation.to = rotationAnimation.to+diff;
}
}
}