Deploy a Qt qml package and remove .qml dependencis
-
I have created a test application in Qt5.9.4. Where i have use DropShadow by importing QtGraphicalEffects 1.0. While creating an .exe for windows, i have copied all the required dll from the C:\Qt\Qt5.9.4\5.9.4\msvc2015\qml folder to the release folder. Where in there is DropShadow.qml present in it. If i remove the .qml the .exe does not launch. Below is the code in the main.qml. How do i remove the .qml dependency?
Window {
id: window1 visible: true width: 800 height: 480 title: qsTr("Transics") Rectangle { id: background anchors.fill: parent color: "white" DropShadow { id: _dropShadow visible: true anchors.fill: whiteBox horizontalOffset: 0 verticalOffset: 4 radius: 10 samples: 20 color: "#26000000" source: whiteBox } Rectangle{ id: whiteBox anchors.fill: parent color: "white" anchors.margins: 100 } }
}
-
If you want to include your QML file in the executable, you can use the Qt resource system to manage your QML file as a resource: https://doc.qt.io/qt-5/resources.html.
-
@sebastienc it is true that for "my qml file" (or in this case, @Joe47 's qml file), the resource system can take all the custom qml files in a project and compile them into a binary, so that when we "ship" our binary to another machine for use by other users, there aren't "loose" qml files that need to be present in the proper locations in order for the app to launch.
However, I think @Joe47 is referring to a qml file that is part of the Qt framework itself. (@Joe47 feel free to clarify). I think that in this case,
DropShadow.qml
is not a file that Joe wrote, but rather part of https://doc.qt.io/qt-5/qml-qtgraphicaleffects-dropshadow.htmlI have not needed to package a Windows QML for distribution recently, so I'm not sure what options there are.
It seems that even windeployqt will leave the qml files "loose", but will make sure to copy them to the right place.
If a directory is passed with the --qmldir argument, windeployqt uses the qmlimportscanner tool to scan QML files inside the directory for QML import dependencies. Identified dependencies are then copied to the executable's directory.
Is there a way to take
qml
files that are internal to Qt (like those below) and have them be compiled into a DLL or EXE instead of "just sitting in a folder" on a required path?./qtgraphicaleffects/src/effects/FastBlur.qml ./qtgraphicaleffects/src/effects/GammaAdjust.qml ./qtgraphicaleffects/src/effects/ColorOverlay.qml ./qtgraphicaleffects/src/effects/DirectionalBlur.qml ./qtgraphicaleffects/src/effects/LevelAdjust.qml ./qtgraphicaleffects/src/effects/DropShadow.qml ./qtgraphicaleffects/src/effects/Blend.qml ./qtgraphicaleffects/src/effects/HueSaturation.qml
I don't know the answer. My aim here is to clarify the question. @Joe47 please correct me if my attempted clarification is unwanted and/or going in a wrong direction.
-
@KH-219Design Yes it is correct.