我可以收到通知吗

我可以收到通知吗

本文介绍了当一个项目完成重绘时,我可以收到通知吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在制作一个项目的快照(通过 ShaderEffectSourcelive: false),但我有时(200 例中有 1 例)得到一个空白快照.我正在根据这样的信号制作快照:

I'm making a snapshot (via a ShaderEffectSource with live: false) of an Item, but I'm sometimes (1 cases in 200) getting a blank snapshot. I'm making the snapshot based on a signal like this:

Image {
    onStatusChanged: {
        if (status == Image.Ready) {
            snapshotter.makeSnapshot();
        }
    }
}

这只是作为一个整体背景.我暂时不会发布测试用例,因为它是一个大应用程序,而且我还没有隔离测试用例.这可能对未来的问题很重要.

This is just as an overall context. I won't post a testcase for now because it's a big app and I haven't yet isolated a testcase. That might be material for a future question.

所以我还没有问我的代码中的错误在哪里".相反,我有一个简单的问题,我认为可以帮助我修复错误:

So I'm not asking "where's the bug in my code" yet. Instead I have a simple question that I think may help me fix the bug:

我可以在项目完成重绘时收到通知吗?

基本原理:也许当我得到 status == Image.Ready 时,图像只是 加载 并且尚未将加载的数据绘制到屏幕外表面.因此,如果我想要的信号存在,我可以连接到 it 而不是连接到 Image.statusChanged.

Rationale: Maybe when I get status == Image.Ready, the Image has merely loaded and not yet painted the loaded data into the offscreen surface. So if my desired signal exists, I could hook onto it instead of hooking onto Image.statusChanged.

注意:我可以实现自己的 NotifyingImage 组件,该组件的工作方式类似于 Image 但另外还公开了一个 repainted 信号.但我想知道是否有内置方式.

Note: I could implement my own NotifyingImage component that works like Image but additionally exposes a repainted signal. But I'd like to know if there's a built-in way.

相关问题: "QQuickItem 时获得通知需要更新".但是,询问者对知道何时更新项目 data 感到满意,我询问的是 repainted 信号,这是稍后发生的事情 比他要求的要多.

Related question: "Get notified when QQuickItem will need updating". But there the asker is satisfied with knowing when the item data is updated, and I'm asking about a repainted signal, which is something that happens later than what he's asking for.

推荐答案

据我所知,Window 总是作为一个整体呈现.所以你可以使用 WindowafterRendering 信号.

As far as I know a Window is always renderd as a whole. So you might use the Window's afterRendering signal.

缺点:当窗口中的任何内容发生变化时,它就会被触发.但结合 (status == Image.Ready) 它可能对你有用.

The downside: It will be triggered, when ever anything in the window has changed. But combined with the (status == Image.Ready) it might work for you.


在一篇博文中,宣布发布Qt5.8Qt Companies CTO写道:

此外,场景图现在支持部分更新屏幕,如果只有一小部分场景发生变化.这为 Qt Quick 2D 渲染器带来了一些更大的性能改进.

我不知道信号afterRendering的实现细节,所以我无法判断在这样的部分更新之后是否触发,如果是,如何告诉您,该部分更新是否与您感兴趣的那部分有关.

I don't know the implementation details of the signal afterRendering, so I can't tell whether this is triggered after such a partial update and if so, how to tell, whether that partial update concerned that part, you are interested in.

这篇关于当一个项目完成重绘时,我可以收到通知吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-22 23:42