QML给Rectangle添加阴影

1.

import QtGraphicalEffects 1.15
 Rectangle {
        id: frame
        width: root.width
        height: root.height
        anchors.centerIn: parent
        color: "#2B2B2B"
        radius: 6
        layer.enabled: true
        layer.effect: DropShadow {
            horizontalOffset: 3   // 水平偏移
            verticalOffset: 3     // 垂直偏移
            radius: 8.0           // 模糊半径
            samples: 16           // 阴影采样数(影响平滑度)
            color: "#80000000"    // 阴影颜色(带透明度)
        }
}

 

posted @ 2025-08-08 23:01  朱小勇  阅读(34)  评论(0)    收藏  举报