Important: Please read the Qt Code of Conduct -

Call function when state transition finishes?

  • Hello. How can I run a function when a state transition animation finishes? For example, when a certain state is entered I fade out an overlay and would like to disable it when the animation is finished so it ceases to capture mouse events.

  • Hmmm I updated my import statement from 2.2 to 2.12 and now an onFinished property is available, however this signal never seems to be called. Apparently this happens when running is not set, but setting this property caused an error (QML OpacityAnimator: setRunning() cannot be used on non-root animation nodes).

    In the end I gave up trying to use the transitions. Instead I moved the overlay to it's own component, created a visible and hidden state for it and gave it a public bool property to control its animated visibility. On the main window state change I simply set this public property of the overlay component to true or false, and the in the overlay component I use the onPropertyChanged event to run some code which manually starts and stops the relevant animation (one for fade in and another for fade out). Also I think because the OpacityAnimator is at the root level of the overlay QML component it doesn't error and the onFinished() signal works as expected.

    I am genuinely suprised at how difficult this has been.

Log in to reply