【问题标题】:Directional Shadows in QMLQML 中的定向阴影
【发布时间】:2021-06-25 13:57:56
【问题描述】:

是否可以在 QML 元素上定义定向阴影,以便仅在对象的一侧投射阴影?

我只能找到DropShadow 元素。但这会在所有侧面产生阴影,可以使用偏移量来移动。但是阴影总是会比原来的对象大。

我想要一个非常类似于this answer 中关于 CSS 中阴影的问题的内容。

【问题讨论】:

    标签: qt qml shadow


    【解决方案1】:

    作为attached的链接

    这个使用渐变色,不要和阴影混淆。

      Rectangle
    {
        x: 150
        y: 111
        width: 152
        height: 112
        color: "#1e8784"
    
        Rectangle
        {
            x: 0
            y: 97
            width: 152
            height: 15
            color: "#f159bf"
    
            gradient: Gradient {
                GradientStop {
                    position: 0.00;
                    color: "#ff20a2";
                }
                GradientStop {
                    position: 0.42;
                    color: "#f583cf";
                }
                GradientStop {
                    position: 1.00;
                    color: "#ffffff";
                }
            }
    
        }
    
    
    }
    

    【讨论】:

    • 谢谢,这正是我想要的!在渐变中从颜色到透明度模拟“阴影”行为。
    猜你喜欢
    • 2015-06-13
    • 1970-01-01
    • 1970-01-01
    • 2021-10-06
    • 1970-01-01
    • 1970-01-01
    • 2017-03-19
    • 2018-06-20
    • 1970-01-01
    相关资源
    最近更新 更多