QML类型说明-AnchorAnimation

本文介绍Qt Quick中的AnchorAnimation,一种用于动画化锚点变化的组件。通过改变目标对象的锚点来实现平滑过渡,适用于状态变化动画。文章提供了一个使用AnchorAnimation的示例。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

AnchorAnimation

ImportStatement:   import QtQuick2.2

Inherits:     Animation

 

Properties

duration : int

easing

easing.type : enumeration

easing.amplitude : real

easing.overshoot : real

easing.period : real

targets : list

 

DetailedDescription

AnchorAnimation用于描述动画的锚的变化。

下面的代码片断,我们右锚接一个矩形到动画。

import QtQuick 2.0

Item {

id: container

width: 200; height: 200

Rectangle {

id: myRect

width: 100; height: 100

color: "red"

}

states: State {

name: "reanchored"

AnchorChanges { target: myRect; anchors.right:container.right }

}

transitions: Transition {

// smoothly reanchor myRect and move into newposition

AnchorAnimation { duration: 1000 }

}

Component.onCompleted: container.state ="reanchored"

}

当AnchorAnimation被用在过渡中,它将在状态变化时发生锚改变动画。它用AnchorChanges.target属性重置指定的目标。

注意AnchorAnimation仅仅只能用于Transition并和一个AnchorChange结合。它不能用于behaviors和其他类型的动画。同时参阅Animation、Transitions以及AnchorChanges。

 

PropertyDocumentation

duration : int

动画持续的时间,以毫秒为单位。默认值是250。

 

easing group

easing.type : enumeration

easing.amplitude : real

easing.overshoot : real

easing.period : real

指定动画曲线。至少需要指定类型。对一些曲线,我们还可以指定振幅、时间和过冲。默认的动画曲线是线性的。

示例代码:

AnchorAnimation { easing.type: Easing.InOutQuad}

同时参阅PropertyAnimation::easing.type文档了解动画曲线的不同类型。

 

targets : list

重新锚定的目标。如果没有指定,那所有的AnchorChanges将被AnchorAnimation动画化。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值