qml毛玻璃效果

此文仅作为记录,若有疑问之处,请在评论区留言,我会一一回复,但看几率。

点赞此文,回复几率:10%

点赞并收藏此文,回复几率:50%

关注、点赞并收藏此文,回复几率:99.99%


先看运行效果:


详细代码如下: 

import QtQuick
import QtQuick.Controls.Material
import QtQuick.Controls
import QtQuick.Effects//*

Item {
    id: rootItem

    Image {
        id: backgroundItem
        source: "img/bg.jpg"
        anchors.fill: parent
    }

    Item {
        id: maskItem
        anchors.fill: panelArea
        layer.enabled: true
        layer.smooth: true
        visible: false
        component PanelMask: Rectangle {
            required property Item item
            x: item.x; y: item.y
            width: item.width; height: item.height
            radius: item.radius
        }
        PanelMask {
            item: toolbar
        }
    }

    MultiEffect {
        anchors.fill: parent
        source: backgroundItem
        autoPaddingEnabled: false
        maskEnabled: true
        maskSource: maskItem
        maskThresholdMin: 0.5
        maskSpreadAtMin: 1.0
        blurEnabled: true
        blurMax: 80
        blur: slider.value
        saturation: 0.1    //饱和度
        brightness: 0.1
    }

    component Panel: Rectangle {
        id: component
        property string text
        property real blurValue
        width: 600; height: 400
        radius: 15
        color: "transparent"
        border.width: 1; border.color: "#8090A0"
        Text {
            anchors.horizontalCenter: parent.horizontalCenter
            anchors.top: parent.top
            anchors.topMargin: 20
            text: component.text
            font.pixelSize: 30
            color: "white"
            layer.enabled: true
            layer.effect: MultiEffect {
                shadowEnabled: true; shadowBlur: 0.4; shadowOpacity: 1.0
            }
        }
    }

    Item {
        id: panelArea
        anchors.fill: parent
        Panel {
            id: toolbar
            anchors.centerIn: parent
            width: rootItem.width/2; height: rootItem.height/2
            text: "实际显示的毛玻璃效果区域"
            Slider {
                id: slider
                anchors.centerIn: parent
                value: 0.8
                Material.accent: "white"
            }
        }
    }
}
  • 4
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

喵呜角角

如果对你有所帮助,哪怕1毛钱~

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值