Can modal Popup have mazimum darkness?
Unsolved
QML and Qt Quick
-
I'm looking for a way to have multiple modal popups with opacity of %60 maximum.
I have a popup something like this...
Popup { id: myPopup width: 400 height: 400 visible: true modal: true Overlay.modal: Rectangle { color: "#9A000000" // #9A means 60% opacity } }
But if two open then the opacity adds and the background becomes darker. I'd like to to remain 60% no mater how many popups there are at one time.
So far, the only solution I've found is to have a reference counter var and use it. If the count is greater than 1, then the popup
dim
is set to false.Popup { id: myPopup width: 400 height: 400 visible: true dim: !(window.popupCount > 1) modal: true Overlay.modal: Rectangle { color: "#9A000000" // #9A means 60% opacity } onOpened: { window.popupCount++ } onClosed: { window.popupCount-- } }
This works, but it's led to the
popupCount
calculations spreading around the code base. Is there something like a global modal max opacity setting I could use instead?Thanks,
Chris