Qt Forum

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

    Solved QML LinearGradient console log warning

    General and Desktop
    2
    3
    626
    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.
    • O
      onimusha last edited by aha_1980

      Hi, i'm trying to add a linear gradient to a rectangle. But in doing so i get he following console log: ShaderEffectSource: 'recursive' must be set to true when rendering recursively.

      Simple question why do i have to put my linear gradient like this:

      Rectangle{
              id: mainRec
              width: parent.width - 15
              height: parent.height - 18
              anchors.centerIn: parent
              radius: 25
          }
      
          LinearGradient{
              anchors.fill: mainRec
              source: mainRec
              start: Qt.point(0, 0)
              end: Qt.point(mainRec.width, mainRec.height)
              gradient: Gradient {
                  GradientStop { position: 0.0; color: "#3B4567" }
                  GradientStop { position: 1.0; color: "black" }
              }
          }
      

      instead of:

      Rectangle{
              id: mainRec
              width: parent.width - 15
              height: parent.height - 18
              anchors.centerIn: parent
              radius: 25
              
              LinearGradient{
                  anchors.fill: parent
                  source: parent
                  start: Qt.point(0, 0)
                  end: Qt.point(parent.width, parent.height)
                  gradient: Gradient {
                      GradientStop { position: 0.0; color: "#3B4567" }
                      GradientStop { position: 1.0; color: "black" }
                  }
              }
          }
      

      to avoid the warning mentioned above? Although i'm getting the correct result when adding later more items inside the rectangle i have to do that outside mainRec brackets which i'm not supposed to because that one has to be the main parent.

      Resistance Is Futile. Your biological and technological distinctiveness will be added to our own.

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

        @onimusha
        The LinearGradient element takes the source element for rendering. So if you put the LinearGradient element as a child of that source element it would render itself recursively, as the warning message says.

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

        O 1 Reply Last reply Reply Quote 4
        • O
          onimusha @raven-worx last edited by

          @raven-worx Oh i see, thanks, plus i just came across this in the docs Note: It is not supported to let the effect include itself, for instance by setting source to the effect's parent. so that explains why.

          Resistance Is Futile. Your biological and technological distinctiveness will be added to our own.

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