Qt Jenny:Java 代码生成器

Qt Jenny 将 Java API 转换为 Qt C++ 封装器,允许 Qt C++ 程序调用 Java 功能。这在使用 Java 系统 API 的平台(如 Android)上尤其有用。

功能

Qt Jenny的功能:

  • 为任何 Java 类生成封装器。
  • 模板化生成,可自定义模板,更改模板可自定义 C++ 输出。
  • 可配置生成,允许控制生成的封装程序的命名空间。
  • 支持在生成的代码中使用QJniObject ,从而利用QJniObject 带来的所有便利。

示例

有关如何使用Qt Jenny 的示例,请参见QtJenny 演示

Qt Jenny 如何工作

Qt Jenny 通过使用以下构建模块将 Java API 转换为 Qt C++ 封装:

  • 导入要封装的类的 Kotlin 代码。
  • 代码中的注解,告诉我们要封装哪些类。
  • 读取注释并生成封装代码的代码生成器。

有了这些构件后,Qt 项目的结构就变成了一个独立的 Gradle 项目,用于生成 Qt CMake 项目使用的代码。CMake 项目会在项目配置时(即运行 CMake 时)触发代码生成。

工作原理

参考资料

许可证和属性

Qt Jenny potentially 包含第三方模块,采用以下许可协议:

© 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.