Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Solved ShaderEffectSource warning without using it explicitly

    QML and Qt Quick
    2
    2
    1094
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • M
      Mark81 last edited by

      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.

      raven-worx 1 Reply Last reply Reply Quote 0
      • raven-worx
        raven-worx Moderators @Mark81 last edited by

        @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.

        --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
        If you have a question please use the forum so others can benefit from the solution in the future

        1 Reply Last reply Reply Quote 5
        • First post
          Last post