【问题标题】:DropShadow with ItemDelegate background具有 ItemDelegate 背景的 DropShadow
【发布时间】:2021-02-18 08:54:11
【问题描述】:

添加 DropShadow 后出现失真。 为什么会出现失真?

QML ListView 失真:

或者也许还有另一种方法可以给元素添加阴影? 这是应用程序的完整代码:main.qml - main 委托 - propertiesview

delegate: PropertiesView {
            id: delegateElement
            anchors.left: parent.left
            anchors.leftMargin: 10
            anchors.right: parent.right
            anchors.rightMargin: 10

            background: Rectangle {
                id: elementDevice
                implicitWidth: 100
                implicitHeight: 40
                opacity: enabled ? 1 : 0.3
                color: delegateElement.down ? "#dddedf" : "#eeeeee"
            }

            DropShadow {
                anchors.fill: parent
                cached: true
                horizontalOffset: 3
                verticalOffset: 3
                radius: 8.0
                samples: 16
                color: "#80000000"
                source: parent
            }
        }
    }

【问题讨论】:

    标签: qt qml


    【解决方案1】:

    试试这个

    delegate: Item{
            anchors.left: parent.left
            anchors.leftMargin: 10
            anchors.right: parent.right
            anchors.rightMargin: 10
            implicitHeight: delegateElement.implicitHeight
    
            PropertiesView {
                id: delegateElement
                anchors.fill: parent
                smooth: true
                opacity:  0
                background: Rectangle {
                    implicitHeight: 40
                    opacity: enabled ? 1 : 0.3
                    color: delegateElement.down ? "#dddedf" : "#eeeeee"
                }
            }
    
            DropShadow {
                anchors.fill: delegateElement
                source: delegateElement
                cached: true
                horizontalOffset: 3
                verticalOffset: 3
                radius: 8.0
                samples: 16
                color: "#80000000"
    
            }
    
        }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2017-02-21
      • 1970-01-01
      • 2016-12-29
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-05-31
      • 2016-12-12
      相关资源
      最近更新 更多