Qt Jenny 配置
选择要为其生成封装类的 Java 类
您可通过在代码生成项目的源文件中,于GenerateCppCode Kotlin类的顶部为目标Java类添加Kotlin导入语句和NativeProxyForClasses 注解,来选择需要生成C++代码的Java类。QtJenny演示项目中提供了以此方式实现的注解示例。
配置代码生成
代码生成器提供了一些配置参数,可用于根据您的项目结构进行调整:
jenny.outputDirectoryoutput目录,即代码的生成位置。 会将生成的文件添加到指定目录下的 jenny/proxy 目录中。Qt Jennyjenny.templateDirectory,即template目录,用于加载代码生成所用的模板。
此外,Qt Jenny 项目还需要将属性
jenny.headerOnlyProxy设为 true,jenny.useJniHelper为 false,并将jenny.useTemplates设置为 true。
这些标志及其默认值的存在,是为了与Qt Jenny 最初分叉自的项目保持向后兼容性。这意味着Qt Jenny 可以配置为以与原始项目相同的方式生成代码。不过,推荐的做法是使用QJniObject 中的模板来生成代码。
© 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.