项目完成重绘后,可以收到通知吗? [英] Can I be notified when a Item has finished repainting?

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

问题描述

我正在创建一个项目的快照(通过 ShaderEffectSource live:false ),但我有时候(200例中有1例)获得空白快照。我根据这样的信号制作快照:

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

这只是一个整体上下文。我现在不会发布一个测试用例,因为它是一个很大的应用程序,我还没有隔离一个测试用例。这可能是未来问题的材料。



所以我没有问我的代码中的错误在哪里。相反,我有一个简单的问题,我认为可能会帮助我解决这个错误:



当项目完成重绘时,我可以收到通知吗? / p>

理由:也许当我得到 status == Image.Ready ,图像只有加载<强>并且尚未将加载的数据绘制到屏幕外表面。所以如果我想要的信号存在,我可以钩住,而不是钩在 Image.statusChanged



注意:我可以实现自己的 NotifyImage 组件,类似于 Image 但另外暴露了一个重绘的信号。但是我想知道是否有内置的方式。



相关问题:当QQuickItem需要更新时收到通知。但是,asker对于知道项目数据是否更新感到满意,而且我正在询问一个重绘的信号,这是发生的事情

解决方案

据我所知,窗口总是作为renderd。所以你可以使用窗口 afterRendering 信号。



缺点:它会被触发,窗口已经改变了。但是结合(status == Image.Ready)可能适用于您。



编辑:

写道:


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


我不知道信号的实现细节 afterRendering ,所以我不知道这是否在这样的部分更新之后触发了,如果是这样,怎么知道这部分更新是否涉及该部分,你有兴趣。


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:

Can I be notified when a Item has finished repainting?

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.

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.

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.

解决方案

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

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.

EDIT:
In a blog post, announcing the release of Qt5.8 the Qt Companies CTO wrote:

In addition, the scene graph now supports partial updates to the screen if only a small area of the scenography changed. This brings some larger performance improvements to the Qt Quick 2D renderer.

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.

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

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆