0
votes

I am creating a Qt QML application using Qt 5.12 and QtQuickControls 2

Everything is working Ok when I develop on desktop and deploy on android device.

The problem is when I want to deploy for a desktop and using the Qt windeploy with --qmldir argument all QML source files from QtQuick module is copied to the final output folder As there is no security in availability of th QML sources, I manualy remove theme from the folder but then the application does not run.

I also tried to put all 800~900 QML files of QtQuick module in resource qrc file, but the result was the same.

How can I omit the QtQuick plain QML files from the application release and hide them from the user?

Thanks in advance

2
Why the question is down voted? any problem in it?AshkanVZ

2 Answers

0
votes

Qt has multiple licenses, now you are probably using the LGPLv3 which allow you to use Qt as you want but as a dynamic library so you have to keep the dll and the Qt qml directory with your application.

What you want to do will need Qt to be added statically with your application. In order to do that you have to use the commercial license of Qt.

Also, using Android mean you use the apk and then does not respect the LGPLv3 licensing. So you cannot sell your application or does money with it on Android.

0
votes

After searching and testing and compiling for a complete 3 days, I reached to this:

Step 0: Use Qt resource files to put your own QML files in it

Step 1: Compile the application as usual with the dynamic linking

Step 2: Copy the final output binary in an empty folder

Step 3: Run windeploy.exe on the file and use --qmldir with the address of the folder containing your QMLs. This should add all plugins in the correct directory hierarchy (which is the key)

Step 4: Remove all QML files (*.qml) from all folders created by windeploy. The remaining are *.dll, plugins.qmltypes, qmldir files (which also are the other keys that let the removing of plain QML files)

Step 5 (Optional): You can also put all plugins.qmltypes, qmldir files (which are plain text files and can simply be edited by the end user) in to a Qt resource file (but the hierarchy of folders must remain the same in the resource file) by cut and pasting theme in to the root of the source folder and adding them to the qrc file, then use this code in your main function:

engine.addImportPath(QStringLiteral("qrc:/"));

Note: If step 5 is used, there could be some problem in using of QML styles other than Default (like Univeral, ...) but without step 5, all styles are usable