QML学习实例

本文介绍了使用QML实现的多种动态效果,包括图片水平和垂直平移、地震效果、飞出过渡、翻页动画、旋转及翻转180度等。通过示例代码展示了如何创建这些视觉效果,如利用PropertyAnimation和SequentialAnimation进行图片位置变换,以及使用Flipable组件实现翻转效果。
摘要由CSDN通过智能技术生成

 

QML学习实例图片切换

1.       水平平移

importQt4.7

 Rectangle{

     width:360;height:630

     Image{

         id:front

         source:"1.png"

         Image{

             id:back

             source:"2.png"

     //PropertyAnimationonx{ to:360;duration:1000;loops:Animation.Infinite}

     //PropertyAnimationony{ to:630;duration:1000;loops:Animation.Infinite}

        SequentialAnimationonx{

                                      id:animation2

                                      running:false

        NumberAnimation  { to:360;duration:1000}

}}

                MouseArea{

                          anchors.fill:parent

                          onClicked:animation2.running=true

}

}

}

 

2.       垂直平移

importQt4.7
Rectangle{
  
     width:360;height:630
     Image{
  
         id:front
         source:"1.png"
         Image{
  
             id:back
             source:"2.png"
     //PropertyAnimationonx{
   to:360;duration:1000;loops:Animation.Infinite}
     //PropertyAnimationony{
   to:630;duration:1000;loops:Animation.Infinite}
        SequentialAnimationony{
  
                                      id:animation2
                                      running:false
        NumberAnimation  {
  to:630;duration:1000}
}}
                MouseArea{
  
                          anchors.fill:parent
                          onClicked:animation2.running=true
}
}
}

 

3.       地震效果

importQt4.7
Rectangle{
  
     width:360;height:630
     Image{
  
         id:front
         source:"1.png"
         Image{
  
             id:back
             source:"2.png"
             MouseArea{
  anchors.fill:parent;onClicked:{animation1.running=true;animation2.running=true;Component.onCompleted=back.destroy(1000)}}
             SequentialAnimationonx{
  
                 running:false
                 id:animation1
                      loops:50
                      PropertyAnimation{
  easing.type:Easing.InOutElastic;to:8  ;duration:10}
                      PropertyAnimation{
  easing.type:Easing.OutInElastic;to:0;duration:10}
                  }
              SequentialAnimationony{
  
                          id:animation2
                          running:false
                               loops:50
                               PropertyAnimation{
  easing.type:Easing.InOutBounce;to:8  ;duration:10}
                               PropertyAnimation{
  easing.type:Easing.OutInBounce;to:0;duration:10}
                           }}}}

 

4.       左下飞出

importQt4.7
Rectangle{
  
     width:360;height:630
     Image{
  
         id:front
         source:"1.png"
         Image{
  
             id:back
             source:"2.png"
             MouseArea{
  anchors.fill:parent;onClicked:{animation1.running=true;animation2.running=true;Component.onCompleted=back.destroy(1000)}}
             SequentialAnimationonx{
  
                 running:false
                 id:animation1
                      PropertyAnimation{
  to:360;easing.type:Easing.InOutBack;duration:1000;loops:Animation.Infinite}
                  }
              SequentialAnimationony{
  
                          id:animation2
                          running:false
                              PropertyAnimation{
  to:630;easing.type:Easing.InOutBack;duration:1000;loops:Animation.Infinite}
                           }}}}

 

5.       左翻页

importQt4.7
Rectangle{
  
    id:rect
     width:360;height:630
     Image{
  
         id:front
         source:"1.png"
         Image{
  
             id:back
             source:"2.png"
             Behavioronwidth{
  
                 NumberAnimation{
  easing.type:Easing.InOutElastic;duration:1000}
             }
             MouseArea{
  
                 anchors.fill:parent
                 onClicked:back.width=0
           
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值