自加载QML项以来,如何测量QML项出现在屏幕上所需的时间?

时间:2018-12-16 16:21:58

标签: qt time qml loader qquickitem

我如何测量自将QML Loader的 source sourceComponent 属性更改为视觉项实际出现在屏幕上(绘出)后经过的时间?

Loader {
    id: _loader
    source: "MyVisualItem.qml"
}

我已经尝试过使用statusChanged和Component.onCompleted信号,但它们都不够准确-很容易看到实际时间明显更长。

2 个答案:

答案 0 :(得分:1)

根据the diagram in the documentation<script src="https://cdnjs.cloudflare.com/ajax/libs/three.js/99/three.min.js"></script>是您最好的选择:

enter image description here

您需要在设置frameSwapped() / source之前或之后直接连接到该信号。第一次调用它时,您可以检查将其呈现在屏幕上所需的时间。不要忘记以后再断开它。 :)

答案 1 :(得分:0)

QML分析器应解决此问题(例如,参见here

可以实现源更换和装载之间的纯时间测量 loader项本身:

Loader.Ready - the QML source has been loaded
Loader.Loading - the QML source is currently being loaded

loaded signal

This signal is emitted when the status becomes Loader.Ready, or on successful initial load.    
The corresponding handler is onLoaded.

因此请测量发生源更改和onLoaded调用之间的时间