dtech
dtech

Reputation: 49289

Adding resources to QML project results in very slow compilation

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.

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.

Upvotes: 6

Views: 2584

Answers (3)

seb-dal
seb-dal

Reputation: 1

The reason the compilation is slow is because all the resources others than QML files is converted and inserted into a big uchar array in the file build.../[release/debug]/qrc_qml_qmlcache.cpp and then compiled. Depending on the resource (like MP4) to be loaded faster, the resources are uncompressed which make the file even bigger and slower to compile. For the alternative

Upvotes: 0

SGaist
SGaist

Reputation: 928

Qt's resources system will create a .cpp file that will contain an C++ array of compressed binary data of the files you put there so with 2MB of images + a your qml text file, qrc will have to regenerate a pretty big file that also takes time to compile.

More information here

Upvotes: -1

dtech
dtech

Reputation: 49289

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

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.

Upvotes: 10

Related Questions