Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

ShaderEffectSource warning without using it explicitly



  • I wrote this QML object:

    import QtQuick 2.11
    import QtGraphicalEffects 1.0
    
    Rectangle {
        property color activeColor: "black"
    
        id: outer
        color: "transparent"
        clip: true
    
        Behavior on activeColor {
            ColorAnimation { duration: 1000 }
        }
    
        Rectangle {
            id: inner
            width: parent.width
            height: width
            radius: width
    
            LinearGradient {
                anchors.fill: inner
                source: inner
                start: Qt.point(outer.width / 2, 0)
                end: Qt.point(outer.width / 2, outer.height)
                gradient: Gradient {
                    GradientStop { position: 0.0; color: activeColor }
                    GradientStop { position: 1.0; color: "black" }
                }
            }
        }
    }
    

    when I show it or change the activeColor property I get the following warning:

    ShaderEffectSource: 'recursive' must be set to true when rendering recursively.

    I guess it depends on the LinearGradient even if I don't use a ShaderEffectSource directly. But where is the recursion here? And how to set the recursive property to true? It's not a member of LinearGradient.


  • Moderators

    @Mark81 said in ShaderEffectSource warning without using it explicitly:

    I guess it depends on the LinearGradient even if I don't use a ShaderEffectSource directly. But where is the recursion here?

    since the gradient is a child of the source, it will render itself recursively.

    In your case to overcome the error you should place the LinearGradient element next to the source item (as a sibling) and explicitly hide the source item.


Log in to reply