Qt Jenny 配置

选择为哪些 Java 类生成封装程序

您可以在代码生成项目源文件中的GenerateCppCode Kotlin 类顶部添加这些类的 Kotlin 导入语句和NativeProxyForClasses 注释,从而选择要生成 C++ 代码的 Java 类。QtJenny 演示中有这样的注解示例。

配置代码生成

代码生成器有几个配置参数,可根据项目结构进行调整:

  • jenny.outputDirectory output Qt Jenny 会将生成的文件添加到指定目录下,即 jenny/proxy 目录下。
  • jenny.templateDirectory template 目录,用于加载代码生成的模板。

除此之外,Qt Jenny 项目还需要将属性

  • jenny.headerOnlyProxy 为 true、
  • jenny.useJniHelper 设为 false,而
  • jenny.useTemplates 设置为 true。

这些标志及其默认值用于支持与Qt Jenny 最初分叉而来的项目的向后兼容性。这意味着Qt Jenny 可以配置为以与原始项目相同的方式生成代码。不过,推荐的方式是使用QJniObject 模板生成代码。

© 2025 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.