gpt4 book ai didi

animation - QML : Fade in/Fade out animation for Image Element

转载 作者:行者123 更新时间:2023-12-02 03:33:15 27 4
gpt4 key购买 nike

Image 元素的源发生更改时,是否可以有淡入/淡出动画?我需要两个图像元素吗?将其中一个的不透明度从 0 更改为 1,另一个从 1 更改为 0?

最佳答案

做到这一点没有太多麻烦。以这种方式运行动画:

Image {
id: toBeCreated
NumberAnimation on opacity {
id: createAnimation
from: 0
to: 1
duration: 2000
}
Component.onCompleted: createAnimation.start()
}

Image {
id: toBeDeleted
NumberAnimation on opacity {
id: destroyAnimation // start this animation from the function where you want to create new Images
to: 0
duration: 2000
onRunningChanged: {
if (!running) {
console.log("Destroying...")
toBeDeleted.destroy();
}
}
}
}

关于animation - QML : Fade in/Fade out animation for Image Element,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12437518/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com