controlling dimming level behind Drawer?
-
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 // } } } }
-
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 // } } } }
-
@mzimmers Overlay.modal is correct,
if opacity "doesn't work" consider setting the alfa value of your gray
color: "#AAAAAAAA" // #AARRGGBB
@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-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-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...
-
Overlay.modal: Rectangle { property color col: "grey"; Component.onCompleted: col.a = 0.2 color: col }
@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-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.