首页 > 解决方案 > qml 中的 TextField 内的矩形中不能有多个 InnerShadow

问题描述

我希望多个 InnerShadow 位于 TextField 内的矩形中,但我只设法制作了这个,我怎么能做到这一点。

我怎样才能让两个内阴影出现在我的矩形上?

TextField {
    id: textField
    anchors.fill: root
    //anchors.verticalCenter: root.verticalCenter
    text: "text"
    focus: true
    selectByMouse: !editableTextField
    color: colorTexto
    readOnly: !editableTextField
    placeholderText: "--------"
    maximumLength: 100
    font.pixelSize: styleId.textSize.regular.x_large
    font.family: fontName
    echoMode: passwd ? TextInput.Password : TextInput.Normal
    background:

        Rectangle {
            anchors.fill: parent
            id: rectTextFieldId
            color: styleId.colorGeneral.text.dark
            //border.width: 1
            radius: 4
            layer.enabled: true
            layer.mipmap: true

            layer.effect: innerShadowTopId && innerShadowBottomId

            Component {
                id: innerShadowTopId
                InnerShadow {
                    radius: 4
                    samples: 9
                    horizontalOffset: -2
                    verticalOffset: -2
                    color: Qt.rgba(255, 255, 255, 1)
                }
            }

            Component {
                id: innerShadowBottomId
                InnerShadow {
                    radius: 4
                    samples: 9
                    horizontalOffset: 2
                    verticalOffset: 2
                    color: Qt.rgba(0, 0, 0, 0.35)
                }
            }
          }
}//TextField

标签: qtqml

解决方案


推荐阅读