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. Difference in opacity change between rectangle color and image?

Difference in opacity change between rectangle color and image?

Scheduled Pinned Locked Moved QML and Qt Quick
1 Posts 1 Posters 867 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.
  • J Offline
    J Offline
    jdowner
    wrote on last edited by
    #1

    This is something that I have notice for a while and worked around, but I thought I should try to understand the issue better -- perhaps someone here can help? I have an image that is red on a rectangle that is also red. The image is a child of the rectangle. If I animate the opacity of the rectangle from 1 to 0 both the rectangle and image fade out. However, they fade differently so that you can clearly see the square image in the animation.

    I would like to know if there is a way to fade out the rectangle and the image so that the image boundary cannot be seen in the process.

    Here is some code to illustrate the effect,

    @
    import QtQuick 1.0

    Rectangle {
    width: 800
    height: 600
    color: "black"

    Rectangle {
    id: canvas
    color: "red"
    opacity: 0.5
    anchors.fill: parent

    Behavior on opacity {
      NumberAnimation {
        duration: 5000
      }
    }
    
    Image {
      source: "red.png"
      anchors {
        verticalCenter: parent.verticalCenter
        horizontalCenter: parent.horizontalCenter
      }
    }
    
    MouseArea {
      anchors.fill: parent
      onClicked: {
        parent.opacity = 0
      }
    }
    

    }
    }
    @

    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