How to package custom controls in QML?

杀马特。学长 韩版系。学妹 提交于 2019-12-02 04:18:09

How can I create the package for custom QML controls? These controls should not be packaged in the source code form to prevent reverse-engineering.

The question implies that the author has QML custom controls implemented with QML technique itself (not C++). Otherwise that would be already QML C++ PlugIn and provided in the form compiled library or some other form of native code (we can just register QML type and provide the necessary import from within executable).

To implement QML PlugIn (with just QML source code) we should create special type of project. It is convenient to organize as nested subdir project to make it work altogether with the rest of the application. Mind that one plug-in project may contain many new QML types.

And to make QML code not visible we can now compile it with Qt Quick compiler available under certain Qt licenses.

dtech

When built for static linking, since 5.7 Qt will build QML modules as shared libraries, embedding the qml files as resources rather than using them from the file system. So that would be one way to go, go for a static Qt build and build your custom controls as a module.

Another potential, albeit far more complicated approach is already outlined here.

QML files can be included in a QRC profile and used in the code with "qrc:/". When building, they are then included in the target binary, protecting them from indiscrete eyes.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!