Qt Quick路径动画

代码很简单,没啥说的。。。
PathLine定义直线路径,每一个终点坐标
另外还有贝塞尔曲线路径,可以参考帮助文档。

Item {
    id:root1



    Button{
        id:root
        text: "Button"
        width: 180
        height: 80
        x:parent.width/2 - width/2
        y:parent.height/2 - height/2
        Rectangle{
            width: 40
            height: 40
            color: "blue"
            radius: height/2
            id:ball
            PathAnimation{
                id:ani
                running: true
                loops: Animation.Infinite
                target: ball
                duration:5000
                 path:Path{
                     //起点左上
                     startX:0-ball.width
                     startY:0-ball.height
                    //到右上
                     PathLine{
                         x:root.width
                         y:0 -ball.height

                     }
                    //到右下
                     PathLine{
                         x:root.width
                         y:root.height

                     }
                     //到左下
                     PathLine{
                         x:0-ball.width
                         y:root.height

                     }
                      //到左上
                     PathLine{
                         x:0-ball.width
                         y:0-ball.height

                    }
                 }
            }
        }
    }


}

这里写图片描述

  • 1
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值