首页 > 其他 > 详细

qml----动画入门(二、简单的动画实现 NumberAnimation类)

时间:2017-12-27 19:56:48      阅读:499      评论:0      收藏:0      [点我收藏+]

上一节中我们讲了PropertyAnimation类,现在我们来讲讲专门处理数字类型的property。

说起这个NumberAnimation,与PropertyAnimation是表亲,有很多相同的血缘关系,但是塔又重写了from和to两种属性,改成了real类型。下面来个小例子看看

import QtQuick 2.2

Rectangle{
    id: rootItem
    width: 360
    height: 240
    color: "#EEEEEE"

    Rectangle{
        id: rect
        width: 50
        height: 50
        x: 0
        y: 5
        color: "blue"

        MouseArea{
            id: mouseArea
            anchors.fill: parent
            onClicked: {
                animationX.start()
                animationRotation.running = true
                animationRadius.start()
            }
        }

        NumberAnimation{
            id: animationX
            target: rect
            properties:  "x, y"
            to: 200
            duration: 3000
            easing.type: Easing.OutCubic    //设置运动轨迹
        }

        NumberAnimation{
            id: animationRotation
            target: rect
            property: "rotation"
            to: 360
            duration: 3000
            running: false
            easing.type: Easing.OutInQuad
        }

        NumberAnimation on radius {
            id: animationRadius
            to: 25
            duration: 2000
            running: false
        }
    }
}

效果图如下:

技术分享图片

 

qml----动画入门(二、简单的动画实现 NumberAnimation类)

原文:https://www.cnblogs.com/SaveDictator/p/8127386.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!