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. Multiple layers and opacity
Forum Updated to NodeBB v4.3 + New Features

Multiple layers and opacity

Scheduled Pinned Locked Moved QML and Qt Quick
2 Posts 2 Posters 2.3k 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.
  • B Offline
    B Offline
    bkamps
    wrote on last edited by
    #1

    Hi Guys,

    Lets' say I have three rectangles on top of each other. I want the middle want to be half transparent (so opacity: 0.5). But the rectangle on top should not be transparent (so opacity: 1). This doesn't work, all layers on top of the half transparent layer are also half transparent.

    Example:

    @
    Item {
    Rectangle {
    id: bigRect
    z: 0
    width: 100
    height: 100
    color: "black"
    }

    Rectangle {
    id: smallerRect
    z: 1
    anchors.centerIn: bigRect
    width: 50
    height: 50
    color : "white"
    opacity: 0.5
    }

    Rectangle {
    id: smallestRect
    z: 2
    width: 25
    height: 25
    color: "red"
    opacity : 1
    anchors.centerIn: smallRect
    }
    }
    @

    1 Reply Last reply
    0
    • Z Offline
      Z Offline
      ZapB
      wrote on last edited by
      #2

      It works fine here but you have a typo in the last item's anchors line. It should be:

      @
      anchors.centerIn: smallerRect
      @

      Can you post a screenshot of what you see please? All I did was ot fix the above typo and run that file in qmlviewer and then adjust the opacity of smallestRect to see the differences.

      Nokia Certified Qt Specialist
      Interested in hearing about Qt related work

      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