Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. problem anchoring MultiEffect

problem anchoring MultiEffect

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
4 Posts 2 Posters 736 Views 1 Watching
  • 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.
  • mzimmersM Offline
    mzimmersM Offline
    mzimmers
    wrote on last edited by
    #1

    Hi all -

    My application calls for use of the same shadow on many different components. To avoid duplicating code, I created a component to perform the shadowing:

    // Shadow.qml
    
    import QtQuick
    import QtQuick.Effects
    
    MultiEffect {
        required property var shadowTarget
        source: shadowTarget
        anchors.fill: shadowTarget
        ... // a bunch of stuff
    }
    

    This works fine when applied to rectangles and buttons, but when I try to use it on a Pane:

    // Shadow user
    Item {
        Pane {
            id: myPane
        }
        Shadow {
            shadowTarget: myPane
        }
    }
    

    I get an error: "QML MultiEffect: Cannot anchor to an item that isn't a parent or sibling."

    Is there something unique about a Pane that would prevent this from working? It's kind of an odd error message.

    Thanks...

    JoeCFDJ 1 Reply Last reply
    0
    • mzimmersM mzimmers

      Hi all -

      My application calls for use of the same shadow on many different components. To avoid duplicating code, I created a component to perform the shadowing:

      // Shadow.qml
      
      import QtQuick
      import QtQuick.Effects
      
      MultiEffect {
          required property var shadowTarget
          source: shadowTarget
          anchors.fill: shadowTarget
          ... // a bunch of stuff
      }
      

      This works fine when applied to rectangles and buttons, but when I try to use it on a Pane:

      // Shadow user
      Item {
          Pane {
              id: myPane
          }
          Shadow {
              shadowTarget: myPane
          }
      }
      

      I get an error: "QML MultiEffect: Cannot anchor to an item that isn't a parent or sibling."

      Is there something unique about a Pane that would prevent this from working? It's kind of an odd error message.

      Thanks...

      JoeCFDJ Offline
      JoeCFDJ Offline
      JoeCFD
      wrote on last edited by
      #2

      @mzimmers said in problem anchoring MultiEffect:

      QML MultiEffect: Cannot anchor to an item that isn't a parent or sibling.

      Pane and Shadow do not have parent and child relationship.
      anchors.fill: shadowTarget ==>not allowed.

      The following works.

      Rectangle {
          id: parentRect
          width: 200
          height: 200
      
          Rectangle {
              id: childRect
              width: 100
              height: 100
              color: "blue"
      
              anchors.centerIn: parentRect
          }
      }
      
      mzimmersM 1 Reply Last reply
      0
      • JoeCFDJ JoeCFD

        @mzimmers said in problem anchoring MultiEffect:

        QML MultiEffect: Cannot anchor to an item that isn't a parent or sibling.

        Pane and Shadow do not have parent and child relationship.
        anchors.fill: shadowTarget ==>not allowed.

        The following works.

        Rectangle {
            id: parentRect
            width: 200
            height: 200
        
            Rectangle {
                id: childRect
                width: 100
                height: 100
                color: "blue"
        
                anchors.centerIn: parentRect
            }
        }
        
        mzimmersM Offline
        mzimmersM Offline
        mzimmers
        wrote on last edited by
        #3

        @JoeCFD said in problem anchoring MultiEffect:

        Pane and Shadow do not have parent and child relationship

        But in my example, they're siblings, aren't they? The same coding works with buttons; I don't understand why it doesn't work with a Pane.

        JoeCFDJ 1 Reply Last reply
        0
        • mzimmersM mzimmers

          @JoeCFD said in problem anchoring MultiEffect:

          Pane and Shadow do not have parent and child relationship

          But in my example, they're siblings, aren't they? The same coding works with buttons; I don't understand why it doesn't work with a Pane.

          JoeCFDJ Offline
          JoeCFDJ Offline
          JoeCFD
          wrote on last edited by
          #4

          @mzimmers the error message is very clear.

          1 Reply Last reply
          0

          • Login

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