qt4 qml Flipable、Flickable和状态与动画

三十七、Flipable、Flickable和状态与动画

一、状态与动画
属性动画使用PropertyAnimation on x{ to:100; duration:1000 }
import QtQuick 1.0

Rectangle {
width: 300;height: 200
Rectangle{
    id:page; width:50; height:50
    x:0; y:100;
    color:"red"
    PropertyAnimation on x{ to:100; duration:1000 }
    //NumberAnimation on x{ to:100; duration:1000}
    PropertyAnimation on color{ to:"blue:"; duration:1000}
    //ColorAnimation on color{ to:"blue"; duration:1000}
}
}

缓冲曲线,在PropertyAnimation里指定 easing.type
import QtQuick 1.0

Rectangle {
width: 300;height: 200
Rectangle{
    id:page; width:50; height:50
    x:0; y:100;
    color:"red"
    PropertyAnimation on x{ to:100; duration:1000; easing.type: "InOutElastic"}
}
}


状态过度动画 使用

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
QML中的Flickable是一个用于处理滚动和拖动的控件。它提供了一个可滚动的视图区域,可以在其中放置其他内容项。在动态创建项目时,需要将其明确指定为contentItem的父级。例如,可以使用以下代码来动态创建项目并将其添加到Flickable中: ``` Flickable { id: myFlickable function addItem(file) { var component = Qt.createComponent(file) component.createObject(myFlickable.contentItem); } } ``` 这里的myFlickable是一个Flickable控件,addItem函数用于动态创建项目并将其作为contentItem的子项添加到Flickable中。 另外,Flickable还提供了一些边界行为设置,可以控制内容在边界上的滚动效果。比如,在水平边界上轻弹时应用翻转效果,可以使用以下示例代码: ``` import QtQuick 2.12 import QtQuick.Window 2.0 Window { id: root visible: true width: 400 height: 400 title: "hello world" Flickable { anchors.fill: parent contentWidth: image.width contentHeight: image.height Image { id: image source: "qrc:/img.jpg" } id: flickable boundsMovement: Flickable.StopAtBounds boundsBehavior: Flickable.DragAndOvershootBounds transform: Rotation { axis { x: 0; y: 1; z: 0 } origin.x: flickable.width / 2 origin.y: flickable.height / 2 angle: Math.min(30, Math.max(-30, flickable.horizontalOvershoot)) } } } ``` 这里的Flickable包含了一个Image作为contentItem,并应用了边界行为设置和翻转效果。<span class="em">1</span><span class="em">2</span><span class="em">3</span> #### 引用[.reference_title] - *1* [QML 弹力效果(Flickable)](https://blog.csdn.net/weixin_42948436/article/details/117364325)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_1"}}] [.reference_item style="max-width: 50%"] - *2* *3* [QML类型:Flickable](https://blog.csdn.net/kenfan1647/article/details/120662308)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_1"}}] [.reference_item style="max-width: 50%"] [ .reference_list ]

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值