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. [SOLVED]Issue with shadow not rendering correctly.
QtWS25 Last Chance

[SOLVED]Issue with shadow not rendering correctly.

Scheduled Pinned Locked Moved QML and Qt Quick
qtgraphicaleffedropshadow
3 Posts 2 Posters 1.6k 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.
  • E Offline
    E Offline
    ealione
    wrote on 26 Jun 2015, 20:05 last edited by ealione
    #1

    I tried creating a simple button with a shadow effect. Yet because Qt paint the shadow only to the area available to the button I ended up with an ugly looking effect, abruptly cutting the shadow borders.

    import QtQuick 2.2
    import QtGraphicalEffects 1.0
    
    Item {
        id: menuButton
        width: 300
        height: 400
    
        Rectangle {
            id: menuButtonIcon
            x: parent.width - 75
            y: parent.height - 80
            color: Qt.lighter("#C02A25", 1.25)
            width: 60;
            height: 60;
            radius: width * 0.5
            antialiasing: true
            //visible: false;         // Hide the original because dropshadow duplicates it.
        }
    
        DropShadow {
            id: menuButtonIconShadow
            source: menuButtonIcon
            anchors.fill: source
            width: source.width
            height: source.height
            cached: true
            radius: 8.0
            samples: 16
            color: "#70000000"
            smooth: true
            horizontalOffset: 0.0
            verticalOffset: 0.0
            spread: 0.2
            transparentBorder: true
        }
    }
    

    I was not able to find a good way of getting past this, so I decided to split my button in two so as to be able to leave the appropriate free space.

    BaseButton

    import QtQuick 2.2
    
    Item {
        id: baseButton
    
        Rectangle {
            id: buttonIcon
            color: Qt.lighter("#C02A25", 1.25)
            width: 60;
            height: 60;
            radius: width * 0.5
            antialiasing: true
        }
    }
    

    MenuButton

    import QtQuick 2.2
    import QtGraphicalEffects 1.0
    
    Item {
        id: menuButton
        x: parent.width - 75
        y: parent.height - 80
        width: 300
        height: 400
    
        BaseButton {
            id: baseButton
            //visible: false;
        }
    
        DropShadow {
            id: menuButtonIconShadow
            source: baseButton.buttonIcon
            anchors.fill: source
            width: source.width
            height: source.height
            cached: true
            radius: 8.0
            samples: 16
            color: "#70000000"
            smooth: true
            horizontalOffset: 0.0
            verticalOffset: 0.0
            spread: 0.2
            transparentBorder: true
        }
    }
    

    But this time DropShadow had no effect at all.

    Am I doomed to remain shadowless.
    Or will a hero step up and restore the dark side?

    1 Reply Last reply
    0
    • ? Offline
      ? Offline
      A Former User
      wrote on 26 Jun 2015, 21:28 last edited by
      #2

      Hi @ealione!

      Your first code produces this: https://drive.google.com/file/d/0B2D1UtsPfTx-dFJzRDhDajFRSk0/view?usp=sharing . What do you mean by "ugly looking effect, abruptly cutting the shadow borders"?

      1 Reply Last reply
      0
      • E Offline
        E Offline
        ealione
        wrote on 26 Jun 2015, 22:04 last edited by
        #3

        Hey @Wieland,

        You are correct. You can see what I was talking about if instead of true you type True for the transparentBorder tag. For some reason I corrected it on the code I posted here, but not in my original code.

        1 Reply Last reply
        0

        1/3

        26 Jun 2015, 20:05

        • Login

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