将资源添加到 QML 项目会导致编译速度非常慢 [英] Adding resources to QML project results in very slow compilation

查看:45
本文介绍了将资源添加到 QML 项目会导致编译速度非常慢的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在我的项目的资源文件中添加了一些图标,突然对 QML 代码的每一个微小更改都会导致项目运行前的等待时间为 7-8 秒,感觉就像是在重新编译 C++ 代码,但实际上这是从 qrc 文件的编译"延迟.

I have added some icons to the resource file of my project and suddenly every tiny change to the QML code results in 7-8 seconds of wait time before the project is ran, it almost feels like it is recompiling the C++ code, but in reality that's the delay from the "compilation" of the qrc file.

我尝试禁用 qrc 压缩,希望它会变得更快,但没有任何效果.这很奇怪也很烦人,考虑到我使用的是具有快速 CPU 和 SSD 的高端系统——额外的资源只有 2 兆字节,为什么要花这么长时间?将相同的文件以高压缩率添加到存档中大约需要 5 毫秒.

I tried disabling qrc compression in hopes that it will get faster, but it didn't have any effect. This is very strange and annoying, considering the fact I am using a high end system with a fast CPU and SSD - the extra resources are only 2 megabytes, why is it taking so long? Adding the same files to an archive with high compression takes about 5 milliseconds.

推荐答案

好的,仍然不知道为什么它这么慢,但我找到了避免它的方法.

OK, still no clue why is it so slow, but I found a way to avoid it.

问题在于,对于 QML 源的每一个微小更改,都会重新编译整个资源文件.所以我将所有图像移动到另一个资源文件,不需要做任何其他事情,不需要更改路径或任何东西,现在 QML 代码位于不同的资源文件中,并且图像不再在每次更改时重新编译,因此项目会立即启动.

The problem was that for every tiny change to QML sources the entire resource file was recompiled. So I moved all the images to another resource file, didn't have to do anything else, no need to change paths or anything, now QML code is in a different resource file and the one with the images is no longer recompiled on every change, so the project launches instantaneously.

这篇关于将资源添加到 QML 项目会导致编译速度非常慢的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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