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 with opacity for rectangle.

Problem with opacity for rectangle.

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

    I have one parent rectangle with opacity of "0.5" i have added some more components in to it.
    problem is that the child components are also displayed with the opacity of "0.5".
    I tried to specify opacity for child components as 1 but still it is displaying opacity for child components.

    Code spinets:
    @
    Rectangle
    {
    id: mainRect
    anchors.fill: parent;
    visible: true;
    opacity: 0.5;
    color: "black"
    border.width: 0;

        Rectangle
        {
            id: childRect;
            anchors.bottom: parent.bottom;
            anchors.bottomMargin: 20;
            anchors.right: parent.right;
            anchors.rightMargin: 20;
            radius: 30;
            border.width: 5
            opacity: 1
            color: "white"
    

    @

    what might be the problem?

    Thanks.

    1 Reply Last reply
    0
    • T Offline
      T Offline
      task_struct
      wrote on last edited by
      #2

      Child element inherits parent's opacity and adds it's opacity. This is explained "here":http://doc.qt.nokia.com/4.7-snapshot/qml-item.html#opacity-prop . A workaround is

      @
      Rectangle
      {
      id: mainRect
      anchors.fill: parent;
      visible: true;
      opacity: 0.5;
      color: "black"
      border.width: 0
      }

      Rectangle
      {
      id: childRect;
      anchors.bottom: mainRect.bottom;
      anchors.bottomMargin: 20;
      anchors.right: mainRect.right;
      anchors.rightMargin: 20;
      radius: 30;
      border.width: 5
      opacity: 1
      color: "white"
      }
      @

      "Most good programmers do programming not because they expect to get paid or get adulation by the public, but because it is fun to program."

      • Linu...
      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