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. controlling dimming level behind Drawer?
Forum Updated to NodeBB v4.3 + New Features

controlling dimming level behind Drawer?

Scheduled Pinned Locked Moved Solved QML and Qt Quick
7 Posts 3 Posters 613 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.
  • mzimmersM Offline
    mzimmersM Offline
    mzimmers
    wrote on last edited by
    #1

    Hi all -

    I'm using a Drawer, and would like the main display to be "dimmer" than it currently is. How do I control the dimming level? I tried using a Overlay.modal with a Rectangle, but it seems to ignore the Rectangle's opacity setting.

    Thanks...

    import QtQuick 2.12
    import QtQuick.Controls
    import QtQuick.Layouts
    
    ApplicationWindow {
        id: mainWindow
        visible: true
        width: 800
        height: 480
    
        Rectangle {
            id: tile
            height: 100
            width: 100
            color: 'green'
            Text {
                text: "some text here"
            }
    
            MouseArea {
                anchors.fill: parent
                onClicked: drawer.open()
            }
            Drawer {
                id: drawer
                width: 560
                height: mainWindow.height
                edge: Qt.RightEdge
    
                dim: true
                modal: true
                focus: true
                closePolicy: Popup.CloseOnEscape | Popup.CloseOnPressOutsideParent
    //            Overlay.modal: Rectangle {
    //                color: 'gray'
    //                opacity: 0.5
    //            }
            }
        }
    }
    
    
    J.HilkJ 1 Reply Last reply
    0
    • mzimmersM mzimmers

      Hi all -

      I'm using a Drawer, and would like the main display to be "dimmer" than it currently is. How do I control the dimming level? I tried using a Overlay.modal with a Rectangle, but it seems to ignore the Rectangle's opacity setting.

      Thanks...

      import QtQuick 2.12
      import QtQuick.Controls
      import QtQuick.Layouts
      
      ApplicationWindow {
          id: mainWindow
          visible: true
          width: 800
          height: 480
      
          Rectangle {
              id: tile
              height: 100
              width: 100
              color: 'green'
              Text {
                  text: "some text here"
              }
      
              MouseArea {
                  anchors.fill: parent
                  onClicked: drawer.open()
              }
              Drawer {
                  id: drawer
                  width: 560
                  height: mainWindow.height
                  edge: Qt.RightEdge
      
                  dim: true
                  modal: true
                  focus: true
                  closePolicy: Popup.CloseOnEscape | Popup.CloseOnPressOutsideParent
      //            Overlay.modal: Rectangle {
      //                color: 'gray'
      //                opacity: 0.5
      //            }
              }
          }
      }
      
      
      J.HilkJ Offline
      J.HilkJ Offline
      J.Hilk
      Moderators
      wrote on last edited by
      #2

      @mzimmers Overlay.modal is correct,

      if opacity "doesn't work" consider setting the alfa value of your gray

      color: "#AAAAAAAA" // #AARRGGBB
      

      Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct


      Q: What's that?
      A: It's blue light.
      Q: What does it do?
      A: It turns blue.

      mzimmersM 1 Reply Last reply
      1
      • J.HilkJ J.Hilk

        @mzimmers Overlay.modal is correct,

        if opacity "doesn't work" consider setting the alfa value of your gray

        color: "#AAAAAAAA" // #AARRGGBB
        
        mzimmersM Offline
        mzimmersM Offline
        mzimmers
        wrote on last edited by
        #3

        @J-Hilk yeah, that works...clever idea. Currently, I'm using a color defined in a property:

        QtObject {
            property color disabled: "#8a8a99"
        }
        Overlay.modal: Rectangle {
            color: "#c08a8a99"//Colors.disabled
        }
        

        Is there some way I can create a new color on the fly, with the desired alpha channel and the RGB from my color disabled?

        Thanks...

        JoeCFDJ J.HilkJ 2 Replies Last reply
        0
        • mzimmersM mzimmers

          @J-Hilk yeah, that works...clever idea. Currently, I'm using a color defined in a property:

          QtObject {
              property color disabled: "#8a8a99"
          }
          Overlay.modal: Rectangle {
              color: "#c08a8a99"//Colors.disabled
          }
          

          Is there some way I can create a new color on the fly, with the desired alpha channel and the RGB from my color disabled?

          Thanks...

          JoeCFDJ Offline
          JoeCFDJ Offline
          JoeCFD
          wrote on last edited by
          #4
          This post is deleted!
          1 Reply Last reply
          0
          • mzimmersM mzimmers

            @J-Hilk yeah, that works...clever idea. Currently, I'm using a color defined in a property:

            QtObject {
                property color disabled: "#8a8a99"
            }
            Overlay.modal: Rectangle {
                color: "#c08a8a99"//Colors.disabled
            }
            

            Is there some way I can create a new color on the fly, with the desired alpha channel and the RGB from my color disabled?

            Thanks...

            J.HilkJ Offline
            J.HilkJ Offline
            J.Hilk
            Moderators
            wrote on last edited by J.Hilk
            #5

            @mzimmers

            Overlay.modal: Rectangle {
                 property color col: "grey";
                 Component.onCompleted: col.a = 0.2
                 color: col
            }
            

            Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct


            Q: What's that?
            A: It's blue light.
            Q: What does it do?
            A: It turns blue.

            mzimmersM 1 Reply Last reply
            3
            • J.HilkJ J.Hilk

              @mzimmers

              Overlay.modal: Rectangle {
                   property color col: "grey";
                   Component.onCompleted: col.a = 0.2
                   color: col
              }
              
              mzimmersM Offline
              mzimmersM Offline
              mzimmers
              wrote on last edited by mzimmers
              #6

              @J-Hilk that's beautiful...thanks!

              EDIT:

              For anyone reading this down the road, the solution used by @J-Hilk is documented in the QML color page, but it's exceedingly brief:

              A color type has r, g, b and a properties that refer to the red, green, blue and alpha values of the color, respectively. Additionally it has hsvHue, hsvSaturation, hsvValue and hslHue, hslSaturation, hslLightness properties, which allow access to color values in HSV and HSL color models accordingly...

              So, it turns out that you have quite a bit of dynamic access to colors in QML.

              J.HilkJ 1 Reply Last reply
              0
              • mzimmersM mzimmers

                @J-Hilk that's beautiful...thanks!

                EDIT:

                For anyone reading this down the road, the solution used by @J-Hilk is documented in the QML color page, but it's exceedingly brief:

                A color type has r, g, b and a properties that refer to the red, green, blue and alpha values of the color, respectively. Additionally it has hsvHue, hsvSaturation, hsvValue and hslHue, hslSaturation, hslLightness properties, which allow access to color values in HSV and HSL color models accordingly...

                So, it turns out that you have quite a bit of dynamic access to colors in QML.

                J.HilkJ Offline
                J.HilkJ Offline
                J.Hilk
                Moderators
                wrote on last edited by J.Hilk
                #7

                @mzimmers thank you, but thinking about it a bit more, I would rather suggest this one:

                color: Qt.rgba(col.r, col.g, col.b, 0.2)
                

                removes the necessity of a local property and the onCompleted function


                Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct


                Q: What's that?
                A: It's blue light.
                Q: What does it do?
                A: It turns blue.

                1 Reply Last reply
                2

                • Login

                • Login or register to search.
                • First post
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • Users
                • Groups
                • Search
                • Get Qt Extensions
                • Unsolved