在此页面上

Qt Jenny 安装

要安装Qt Jenny :

快速入门方法

以QtJenny 演示项目为起点。该项目已配置好针对一组 Android Java 类的代码生成项目,且该代码生成项目已集成到主 Qt C++ 应用程序项目中。

专家级方法及更详细的说明

  1. 您需要配置一个 Gradle 项目,该项目需依赖qtjenny-annotation 和qtjenny-compiler 。qtjenny-annotation 提供了一个注解处理器,而 qtjenny-compiler 提供了一个KAPT模块。

    Qt Jenny 虽然可以配置为处理 Java 代码中的注解(而非 Kotlin),但这并不重要,因为这些注解并非针对生成项目本身的代码;它们仅用于触发对已定义且可通过某些包(例如 Android SDK 提供的 Android API 类)获取的类生成包装器。

  2. 此外,你还需要一套用于代码生成的模板。 Gradle 依赖项不会安装任何模板,因为这会将它们放置在 Gradle 缓存目录中,在该目录中编辑模板会非常繁琐。虽然并非所有用户都需要修改模板,但为了满足这种可能性,它们是单独安装的。QtJenny Demo的代码生成子项目中已安装了合适的模板。
  3. 完成上述步骤后,运行生成构建。随后,代码即已生成,并可供常规 Qt C++ 项目使用。

    如果 CMake 项目的构建方式与QtJenny 示例中一致,此步骤将在 Qt C++ 项目的配置阶段自动完成。

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