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

查看:17
本文介绍了向 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天全站免登陆