Solved Controls still respond when opacity is 0?
-
I've been writing my own tab control, which adjusts the opacity of the Qt Quick Control 2 views that each tab controls.
That successfully hides and shows the views as expected. There are a few, unexpected side-effects, however.
Some of my controls aren't responding.
Some controls that are hidden are responding. Today I discovered that a ComboBox on a view with opacity 0 still responds when I click on its location on a different tab.
My whole tab view construction was predicated on the idea that controls that are in a parent view with opacity of 0 will not respond to clicks. Is this not the case in qml?
-
No that's not the case.
Controls don't respond when they havevisible
orenabled
set to false.You could change the
visible
property instead in your case.
If you don't want to set thevisible
property directly (you might want to to animate theopacity
to hide a control for example) you could dovisible: opacity > 0
.Note that a
visible
element will have its geometry ignored by containers likeRow
orColumnLayout
. -
Ah, now the unexpected behavior I'm seeing makes sense.
I assume that I only need to change the visibility of the parent Item or Rectangle the tabs are on, and that subviews inherit that property.
Thanks for the help!