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. Opacity and inheritance
Forum Updated to NodeBB v4.3 + New Features

Opacity and inheritance

Scheduled Pinned Locked Moved Solved QML and Qt Quick
qml
3 Posts 2 Posters 677 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.
  • G Offline
    G Offline
    GrahamLa
    wrote on last edited by
    #1

    Hi
    I have a container element that I want to set an opacity value for, but I don't want the 'contained' elements to get this opacity.
    Is there a way of achieving this?
    Container code

    import QtQuick 2.9
    import QtQuick.Window 2.2
    import QtQuick.Controls 2.3
    import QtQuick.Layouts 1.3
    import Qt.labs.location 1.0
    import "../../Customisation"
    
    Rectangle {
        id: frame
        property string title: ""
        property string contentSource: ""
        property string regionColor: ""
        height: label.height + loader.height + base.height
    
        color: "black"
    
        opacity: 0.5
    
        Label {
            id: label
            anchors.right: parent.right
            anchors.rightMargin: 0
            anchors.top: parent.top
            anchors.topMargin: 0
            anchors.left: parent.left
            anchors.leftMargin: 0
            font.pointSize: Style.appSection.fontSize
            color: Style.appSection.titleLabelColor
            text: title.toUpperCase()
            background: Rectangle {
                color: Style.appSection.titleLabelBackgroundColor
                height: 20
            }
        }
    
        Loader {
            id: loader
            anchors.top: label.bottom
            anchors.topMargin: 50
            width: childrenRect.width
            height : childrenRect.height
    
            source: contentSource
    
    
        }
    
        Rectangle {
            id: base
            height: 5
            color: regionColor
            anchors.bottom: parent.bottom
            anchors.bottomMargin: 0
            anchors.right: parent.right
            anchors.rightMargin: 0
            anchors.left: parent.left
            anchors.leftMargin: 0
        }
    }
    
    1 Reply Last reply
    0
    • YashpalY Offline
      YashpalY Offline
      Yashpal
      wrote on last edited by
      #2

      Hi! do not set opacity, instead set container rectangle color with alpha value
      color: "#80000000" should give you the desired outcome.

      Cheers!!

      G 1 Reply Last reply
      5
      • YashpalY Yashpal

        Hi! do not set opacity, instead set container rectangle color with alpha value
        color: "#80000000" should give you the desired outcome.

        Cheers!!

        G Offline
        G Offline
        GrahamLa
        wrote on last edited by
        #3

        @Yashpal
        Thanks - it worked

        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