Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QML LinearGradient console log warning
Forum Update on Monday, May 27th 2025

QML LinearGradient console log warning

Scheduled Pinned Locked Moved Solved General and Desktop
3 Posts 2 Posters 839 Views
  • 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 Offline
    O Offline
    onimusha
    wrote on last edited by aha_1980
    #1

    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-worxR 1 Reply Last reply
    0
    • O onimusha

      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.

      raven-worxR Offline
      raven-worxR Offline
      raven-worx
      Moderators
      wrote on last edited by
      #2

      @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
      4
      • raven-worxR raven-worx

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

        O Offline
        O Offline
        onimusha
        wrote on last edited by
        #3

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

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved