I have created this function in my QML file:
function setPanelOpacity(panel, visiblePanel) {
panel.opacity = (panel === visiblePanel) ? 1 : 0;
}
This works, but I would like to have the opacity change take 0.5 seconds instead of happening all at once. How can I do that inside this function? (I have seen examples that use states and transitions defined inside a QML object, but nothing that does this entirely within a function like my function here)
Edit: I see that I can achieve this (somewhat) by adding a Behavior
to each of my panel objects, like so:
Behavior on opacity {
NumberAnimation {
duration: 500
easing.type: Easing.InOutQuad
}
}
Having to add this block to all of my objects is a bit of a pain, though. Is there any way to achieve this fully programmatically inside my method, or alternatively to apply this Behavior
to every object on my page?