Tip of the day – Make Qt Creator to compile QML files to resource file on every build
Aug 4I like to distribute my QML application so that everything comes with a single binary executable. In practice this means that I have defined that all my QML files are compiled into binary using Qt’s resource compiler. Resource system in Qt is quite nice, but there is annoying bug in Qt creator. Sometimes it doesn’t recompile resources even though I have modified a QML file. This means that you need to select “Clean” and “Build” from Qt creator in order to get modifications compiled. This takes time.
Some time ago, I figured out a workaround for this. You can add a custom build step to your Qt Creator’s project. This build step modifies e.g. an image that is included the project and then resources are recompiled. Here’s a screenshot how you can do it.
I added the custom build step to the first (touch quickflickr.png) and when my project is being compiled it notices that some of the resources have changed and it runs resource compiler too. This is far from an elegant solution, but at least it works for me and I don’t need to run “Clean & Build” which takes for ever. At least, it feels so after you have recompiled your project for the 10th time.
UPDATE: I thought, that there would have been a bug about this but couldn’t find a onet from Qt’s issue tracker so I created a new one: QTCREATORBUG-5743.
I hope this trick will help some one else too. Thanks for reading my blog and thanks for Bale to encourage me to write this “tip of the day” post. Cheers!
