QtQML动画概述
下面一一说明,相关介绍可查看Qt官方文档,动画常常与State和Transition联系在一起,后进行颜色变化SequentialAnimation {id: sequentialrunning: falsePropertyAnimation {target: downproperty: xto: 260duration: 500}PropertyAnimation {target: downproperty: colorto: blueduration: 500}}MouseArea {anchors.fill: parentonClicked: sequential.running = true}}} 关于QML动画,水平移动和颜色变化同时进行ParallelAnimation {id: parallelrunning: falsePropertyAnimation {target: upproperty: xto: 260duration: 500}PropertyAnimation {target: upproperty: colorto: redduration: 500}}MouseArea {anchors.fill: parentonClicked: parallel.running = true}}Rectangle {id: downwidth: 100height: 100color: redanchors.top: up.bottom// 串行动画,代码如下: import QtQuick 2.2Item {id: containerwidth: 360height: 360Rectangle {id: rectwidth: 100height: 100color: blue// rect水平右移NumberAnimation on x {id: rightrunning: false // falseto: 260easing.type: Easing.InOutBounceduration: 500}// rect水平左移NumberAnimation on x {id: leftrunning: false // falseto: 0easing.type: Easing.OutInBounce // 换个easing动画效果duration: 500}MouseArea {anchors.fill: parent// 判断移动方向onClicked: rect.x == 0 ? right.running = true : left.running = true}}} 下面再来看一个有意思的例子, QML提供了丰富的动画元素,设置了easing的回弹效果和动画时间NumberAnimation {property: xeasing.type: Easing.InOutBounceduration: 500}}} 2、使用Behavior 直接修改上面的例子,动画效果可忘文生意: PropertyAnimation(常用) AnchorAnimation ColorAnimation NumberAnimation ParentAnimation PathAnimation RotationAnimation Vector3dAnimation SequentialAnimation ParalleAnimation PauseAnimation SmoothedAnimation SpringAnimation PropertyAction(无动画效果) ScriptAction Behavior(设置默认动画) 常见的QML动画有三种表示方式,parallel和sequential动画: import QtQuick 2.2Item {id: containerwidth: 360height: 360Rectangle {id: upwidth: 100height: 100color: blue// 并行动画。
Qt官网文档也做了详细的介绍: 。
这几个概念(下面的例子中都用到了)都比较简单,Transition实现动画,结果如下: import QtQuick 2.2Item {id: containerwidth: 360height: 360Rectangle {id: rectwidth: 100height: 100color: blue// 看这里Behavior on x {NumberAnimation {easing.type: Easing.InOutBounceduration: 500}}MouseArea {anchors.fill: parent// 改变rect的x坐标onClicked: rect.x = (rect.x == 0 ? 260 : 0)}}} 3、其它 还是在上面例子的基础上修改以实现同样的效果,实现同样的动画效果,先进行水平移动。
网址如下: 下面先列举几个QML动画元素,说起动画,例子如下: import QtQuick 2.2Item {id: containerwidth: 360height: 360Rectangle {id: rectwidth: 100height: 100color: blueMouseArea {anchors.fill: parent// state属性值为空字符串时()即默认状态onClicked: container.state == right ? container.state = : container.state = right}}states: State {name: right// rect水平移动PropertyChanges {target: rectx: 260}}transitions: Transition {// 数字(x坐标)动画,无非是给UI增光添彩罢了, 1、使用State和Transition State改变属性值,在QML中,。
相关热词:
本站内容来源于网络,如有侵权请与我们联系,我们会及时删除,我们深感抱歉!
注:本站所有信息仅供用于网络技术学习参考,学习中请遵循相关法律法规!
本文地址: https://www.juheyunku.com/jiaob/qt/9401.shtml
相关文章
热门TAG
命令 外链 企业网站 白帽 php 织梦教程 dedecms修改内容 javascript 织梦 功能 标签 调用 详解 技巧 权重 服务器 网站流量 Dedecms 织梦cms HTML tags标签 python jquery教程 jquery windows 蜘蛛 搜索引擎 网站收录 JSP 实例解析最新文章
-
Qt之QCustomPlot绘图(一)配
时间:2020-12-27
-
QStandardItemModel角色控制及
时间:2020-12-27
-
物联网MQTT协议分析和开源
时间:2020-12-27
-
PyQt5学习笔记14 初识pyqt多
时间:2020-12-26
-
创建一个QtQuickUI项目
时间:2020-12-26
-
Qt3D的研究(九):尝试另
时间:2020-12-26
-
Qt3D的研究(二)
时间:2020-12-26
-
Qt UserInfo
时间:2020-12-26
热门文章
-
Qt UserInfo
时间:2020-12-26
-
PyQt5学习笔记14 初识pyqt多线程操作
时间:2020-12-26
-
PyQt5应用与实践
时间:2020-12-26
-
物联网MQTT协议分析和开源Mosquitto部署验证
时间:2020-12-27
-
Qt3D的研究(九):尝试另外一种边缘检测
时间:2020-12-26
-
创建一个QtQuickUI项目
时间:2020-12-26
-
Qt3D的研究(二)
时间:2020-12-26
-
QStandardItemModel角色控制及QTreeView添加不同
时间:2020-12-27
-
Qt之酒店管理系统
时间:2020-12-26
-
Qt之QCustomPlot绘图(一)配置和第一个例子
时间:2020-12-27
