qt qml fuzzyPanel 毛玻璃效果

本文介绍使用QML实现毛玻璃效果的方法。通过FastBlur组件对目标元素进行模糊处理,并保持位置同步。提供了完整的代码示例及调用方法。

毛玻璃效果,用qml来写代码真是简短,大爱qml:)

【下载地址】http://download.youkuaiyun.com/detail/surfsky/8426641

【核心代码】

 1 Rectangle{
 2     clip: true
 3 
 4     // 属性
 5     property Item target  // 模糊源
 6 
 7     // 毛玻璃效果
 8     FastBlur {
 9         id: blur
10         source: parent.target
11         width: source.width;
12         height: source.height
13         radius: 64
14     }
15 
16     // 设置模糊组件的位置
17     onXChanged: setBlurPosition();
18     onYChanged: setBlurPosition();
19     Component.onCompleted: setBlurPosition();
20     function setBlurPosition(){
21         blur.x = target.x - x;
22         blur.y = target.y - y;
23     }
24 }

【调用方法】

1     FuzzyPanel{
2         id: panel
3         width: 200;
4         height: 200;
5         x: 200
6         y: 200
7         target: panelBg
8     }

【效果图】

 

转载于:https://www.cnblogs.com/surfsky/p/4275346.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值