我如何测量自将QML Loader的 source 或 sourceComponent 属性更改为视觉项实际出现在屏幕上(绘出)后经过的时间?
Loader {
id: _loader
source: "MyVisualItem.qml"
}
我已经尝试过使用statusChanged和Component.onCompleted信号,但它们都不够准确-很容易看到实际时间明显更长。
答案 0 :(得分:1)
根据the diagram in the documentation,<script src="https://cdnjs.cloudflare.com/ajax/libs/three.js/99/three.min.js"></script>
是您最好的选择:
您需要在设置frameSwapped()
/ source
之前或之后直接连接到该信号。第一次调用它时,您可以检查将其呈现在屏幕上所需的时间。不要忘记以后再断开它。 :)
答案 1 :(得分:0)
QML分析器应解决此问题(例如,参见here)
可以实现源更换和装载之间的纯时间测量 loader项本身:
Loader.Ready - the QML source has been loaded
Loader.Loading - the QML source is currently being loaded
This signal is emitted when the status becomes Loader.Ready, or on successful initial load.
The corresponding handler is onLoaded.
因此请测量发生源更改和onLoaded调用之间的时间