Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Call for Presentations - Qt World Summit

    Problem with opacity for rectangle.

    QML and Qt Quick
    2
    2
    2602
    Loading More Posts
    • 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
      at_pradeep last edited by

      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 Reply Quote 0
      • T
        task_struct last edited by

        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 Reply Quote 0
        • First post
          Last post