QmlBook in chinese 编程之一 ------(大风车吱悠悠的转)

       之前说要把qml搞一下,那就搞一下吧,本章例子是QmlBook in chinese 中的第一个开门见山的例子,大风车。后面我就按照这本书来给大家记录下,大家也可以去对应官网去看例子,基本上例子都是在学习的。

       老规矩,先看效果图吧:

先做好图片的准备 工程建立以后,然后就可以编写对应代码了

代码部分: 

import QtQuick 2.12
//import QtQuick.Window 2.12
import QtGraphicalEffects 1.0

Image {
    id: root
    source: "images/background.png"
    property int blurRadius: 0
    Image {
        id: pole
        anchors.horizontalCenter: parent.horizontalCenter
        anchors.bottom: parent.bottom
        source: "images/pole.png"
    }

    Image {
        id: wheel
        anchors.centerIn: parent
        source: "images/pinwheel.png"

        Behavior on rotation {
            NumberAnimation{
                duration: 250
            }
        }

        layer.effect: FastBlur{
            id:blur
            radius: root.blurRadius
            Behavior on radius {
                NumberAnimation{
                    duration: 250
                }
            }

        }
        layer.enabled: true
    }

    MouseArea{
        anchors.fill: parent
        onPressed: {
            wheel.rotation += 90
            root.blurRadius = 16
        }
        onReleased: {
            root.blurRadius = 0
        }
    }
}

 其实就是每个图片放到对应位置,这里每个知识点后面都会讲解,其实就是转化为功能,让图片动起来,让你感觉到图片在动。

 本书的链接:qmlBook in chinese 提取码:6hfv 
 本例子的链接:本章的例子 提取码:ysqq 
 

喜欢我博客的同学可以关注我博客,后期会把自己积累的学到与积累到的代码与项目分享出来,一起进步。 

 

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值