Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
How to deploy precompiled QML files from QtQuick Controls 2
VRobot last edited by
I’ve built a QtQuick based C++ app. Now, I would like to prepare it for deployment. My app is built with QtQuick Controls 2 and uses Material style. I would definitely like to avoid insane idea of placing a bunch of .qml files for app's UI into app's directory – so I decided to use QtQuickCompiler to precompile all qmls and embed them into the executable. And here is my problem.
I did everything Qt documentation suggests for QtQuickCompiler usage, such as placing my own .qml files (that belong to the project) into resource system. But what about those .qml files that are part of QtQuick Controls 2 and located in Qt SDK folders (like Button.qml, Slider.qml, CheckBox.qml etc)? How would I use them with QtQuickCompiler? I cannot place them into my project resource file since they don't even belong to the project itself. Moreover, many of those style qml files have some inner dependencies on other internal qml files, and also on plugin.dll files. Where would I place those?
I've tried to compile my app with QtQuickCompiler and using windeployqt.exe tool on Windows. I hoped to see what dependencies the tool can find (especially dependencies on qml files from Qt SDK). However, that tool copies the entire QtQuick directory with all qml files located in it into my app's directory. It copies everything Controls.2, Templates.2, Window.2 folders, and all files even the ones I don't use. In any case, windeployqt.exe does precisely what I am trying to avoid – copying qml files as is. What am I doing wrong? How to precompile all qml files in my app so that they are not visible when the app is installed?