保护 QML 源代码免遭剽窃 [英] Protecting QML source code from plagiarism

查看:16
本文介绍了保护 QML 源代码免遭剽窃的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们的目标是想出一种方法来保护您的 QML 代码免遭剽窃.这是一个问题,因为 QML 的设计和实现方式在这方面似乎莫名其妙地不受保护.唯一受保护的 QML 类型是那些完全用 C++ 实现的.

The goal is to come up with a way to protect your QML code from plagiarism. It is a problem, since the way QML was designed and implemented seems to be inexplicably unprotected in this regard. The only QML types which are somewhat protected are those implemented entirely in C++.

  • Qt 资源文件不支持任何程度的保护
  • 即使你压缩了资源文件,从中提取数据对于任何有中等经验的人来说仍然相当简单
  • 存储在文件系统中的 QML 文件实际上可供使用
  • 这同样适用于任何远程 QML 文件,除了增加对 Internet 连接的依赖外,还可以轻松嗅探网络访问并通过其 url 获取 QML 文件
  • QML 似乎没有提供任何公共 API 来允许用户充分控制 QML 类型解析以保护他们的代码

总而言之,Qt 看起来几乎是故意忽略 QML 代码保护,一个明显的候选原因是强迫人们购买具有 QML 编译器的极具表现力的商业许可证.

All in all, it almost looks like Qt deliberately skimps on QML code protection, one obvious candidate reason would be to force people into buying the insanely expressive commercial license, which features the QML compiler.

所以没有任何保护 QML 源的现有方法,目前我想到的唯一解决方案是控制如何解析 QML 类型.向 QML 注册类型有几种方法:

So absent any stock method of protecting QML sources, the only solution that currently comes to my mind is control over how QML types are resolved. There are several ways of registering types to QML:

  • 在应用程序可执行文件中注册
  • 在插件中注册
  • 通过 QML 模块注册

但是,我需要手动解析 QML 类型,就像您可以创建自定义 QQuickImageProvider 输入 URL 字符串并输出图像一样,我需要 QML 引擎来请求字符串我的自定义组件提供程序的类型,它输出准备好对象实例化组件.

However, what I need is to manually resolve QML types, much like you can create a custom QQuickImageProvider which inputs a URL string and outputs an image, I need the QML engine to request a string with the type to my custom component provider which outputs a ready for object instantiation component.

如果使用任何自定义实例化机制,这将很容易,但我需要这些类型可以在常规 QML 源中使用.理想情况下,这应该是用于解析类型的第一个机制,然后再查看可用的导入路径甚至是内部注册的类型.

This would be easy if any custom instantiation mechanism is used, but I need those types to be usable in regular QML sources. Ideally this should be the first mechanism used to resolve the type, before looking in the available import paths or even internally registered types.

另外,如果有一种方法可以完全在 C++ 中定义 QML 模块,没有任何外部 QML 文件,没有 qmldir 文件等等,那将同样有用.

Alternatively, it would be just as useful if there is a way to define a QML module entirely in C++, without any external QML files, without a qmldir file and so on.

作为最后的手段,并且不理想,我还满足于将 QML(不是 C++)类型注册到运行时,这也可能很有用,但我更愿意完全控制解析过程.

As a last resort, and falling short from ideally, I would also settle for registering QML (not C++) types to the runtime, this could also be useful, but I'd prefer to have full control over the resolving process.

QML 插件无法解决问题,因为它注册了 C++ 类型,而我想注册 QML 类型,即从字符串源创建并相互引用的 QQmlComponent.

A QML plugin does not do the trick, as it registers C++ types, and I want to register QML types, that is, QQmlComponents created from string sources and referencing each other.

推荐答案

(理想的)解决方案:预编译

Qt Quick Compiler 是 Qt Quick 应用程序的开发插件,它允许您将 QML 源代码编译成最终的二进制文件.正如它的描述,它将有助于防止抄袭,它还将提高您的应用程序启动时间和提供其他好处.

The (ideal) Solution: Precompile it

The Qt Quick Compiler is a development add-on for Qt Quick applications which allows you to compile QML source code into the final binary. As it's description says, it will help on preventing plagiarism and it will also enhance your application launch times and provide other benefits.

这是尽可能接近保护 QML 源代码的方式,即使它尚未完全优化

从 Qt 5.11 开始,该解决方案已经到位并且正在快速改进.

As of Qt 5.11 the solution is in place and getting better fast.

似乎 QML 编译器已经从5.11 我不知道工具,但 Lars Knoll 在博客文章中解释了它.

Seems the QML compiler is already opensource from 5.11 I can't tell about tooling but Lars Knoll explains it on the blog post.

这篇关于保护 QML 源代码免遭剽窃的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆