在原始条件和 SequentialAnimation 之间切换

发布于 2025-01-10 20:15:12 字数 1226 浏览 2 评论 0原文

不知道如何表达我的问题。我的代码片段只是为了说明我想要在更大的代码库中实现的目标。我有一个“原始条件”,可以改变图像的不透明度,该图像独立于顺序动画。在 SequentialAnimation 完成更改“originalCondition”绑定回不透明度的图像的不透明度后,我想要实现的目标。 不确定绑定是否是描述它的适当方式

由于某种原因,这种情况不会发生,我不确定为什么或如何做到这一点。

Item {
    id: root
    property bool activatedLetter: false

    Button {
       text: "Click me"
       onClicked: root.activatedLetter = true
     }
         
    Image {
        id: headerBackgroundImage
        visible: true
        opacity: originalCondition 
    }

    SequentialAnimation {
        running: root.activatedLetter

        onStopped: {
            if(root.activatedLetter) {
                headerBackgroundImage.visible = true
            }
            headerBackgroundImage.opacity = 1
            root.activatedLetter = false
        }

        PauseAnimation {
           duration: 750
        }

        NumberAnimation {
            target: headerBackgroundImage
            property: "opacity"
            from: 1
            to: 0
            duration: 1000
        }

        NumberAnimation {
            target: headerBackgroundImage
            property: "visible"
            from: 1
            to:0
            duration: 1000
        }
    }
}

Not sure how to express my question. My snippet code is just to illustrate what I want to achieve in a much bigger code base. I have an "originalCondition" that changes the opacity of an image which is independent of the SequentialAnimation. What I want to achieve after the SequentialAnimation has completed changing the opacity for the Image that the "originalCondition" binds back to the opacity. Not sure if bind is the appropriate way to describe it

For some reason, this does not occur and I am not sure why or how to do it.

Item {
    id: root
    property bool activatedLetter: false

    Button {
       text: "Click me"
       onClicked: root.activatedLetter = true
     }
         
    Image {
        id: headerBackgroundImage
        visible: true
        opacity: originalCondition 
    }

    SequentialAnimation {
        running: root.activatedLetter

        onStopped: {
            if(root.activatedLetter) {
                headerBackgroundImage.visible = true
            }
            headerBackgroundImage.opacity = 1
            root.activatedLetter = false
        }

        PauseAnimation {
           duration: 750
        }

        NumberAnimation {
            target: headerBackgroundImage
            property: "opacity"
            from: 1
            to: 0
            duration: 1000
        }

        NumberAnimation {
            target: headerBackgroundImage
            property: "visible"
            from: 1
            to:0
            duration: 1000
        }
    }
}

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

衣神在巴黎 2025-01-17 20:15:12

在你的 onStopped 中,而不是这个:

headerBackgroundImage.opacity = 1

尝试这个:

headerBackgroundImage.opacity = Qt.binding(() => originalCondition);

In your onStopped, instead of this:

headerBackgroundImage.opacity = 1

try this:

headerBackgroundImage.opacity = Qt.binding(() => originalCondition);
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文