How to package custom controls in QML?

99封情书 提交于 2019-12-20 04:58:10

问题


I would like to create a library of QML custom controls that I would provide to my customers. At the same time I don't want my customers to "reverse-engineer" my controls by peeking into the QML source code.

What are my best options to avoid this? The ideal scenario would that I provide my controls as a compiled library that they could import in their own projects.

My target platforms are iOS and Android.


回答1:


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.




回答2:


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.




回答3:


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.



来源:https://stackoverflow.com/questions/42597690/how-to-package-custom-controls-in-qml

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