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

查看:770
本文介绍了保护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文件,除了添加对互联网连接的依赖,很容易嗅探网络访问并通过他们的URL获取QML文件。

  • QML不提供似乎提供任何公共API以允许用户充分控制QML类型解析以保护他们的代码。

  • Qt resource files don't support any degree of protection
  • even if you compress the resource file, extracting data from it is still fairly trivial to anyone with moderate experience
  • QML files stored on the file system are practically there for the taking
  • the same applies to any remote QML files, aside from adding dependency on internet connection, it is easy to sniff on the network access and get the QML files through their urls
  • QML doesn't provide seem to provide any public API to allow users enough control over QML type resolution to protect their code

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.

以前是关闭源,但您可以在 https://github.com/qmlc/qmlc ,或者您可以 等待到Qt 5.8 ,它将成为开源

It used to be closed source, but you can get an alternative opensource version at https://github.com/qmlc/qmlc or you can wait until Qt 5.8 where it will become opensource.

保护您的QML源代码,即使尚未完全优化

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

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