Qt Remote Object(QtRO)解决找不到rep_xx_source.h或rep_xx_replica.h的终极方法

手动生成rep_xx_source.h或rep_xx_replica.h的方法

在用的时候,发现一些问题,我的Qt Creator版本是5.14.1,在使用Qt Remote Object(QtRO),发现几个影响rep_xx_source.h或rep_xx_replica.h生成的问题。

关于.rep书写的格式,参照官方文档:Qt Remote Objects Compiler

REPC_REPLICA = media.rep \
               location.rep

生成的文件命名格式为:

rep_<replica file base>_replica.h
REPC_SOURCE = media.rep \
              location.rep

生成的文件命名格式为:

rep_<replica file base>_source.h

REPC_REPLICAREPC_SOURCE 这两个后加的文件路径是相对于pro文件的,而不是pri文件的,这点要注意,因为我把些放到了pri里,用$$PWD来写相对pri路径,发现怎么都不行,放到pro文件里就可以了。最后确定是路径编写问题,不管你的REPC_REPLICA 和 REPC_SOURCE放都在pro还是pri里,其文件的路径都是相对于pro的,这点切记。

第二点:

关于生成的.h文件名的说明举例:

比如你的rep文件名为:CommonInterface.rep

那么生成的rep_CommonInterface_replica.h和rep_CommonInterface_source.h

这里我遇到了问题,只生成了rep_CommonInterface_replica.h,没有生成rep_CommonInterface_source.h。
然后我手动去生成它。

repc命令的位置和参数

位置在D:\Qt\Qt5.14.1\5.14.1\mingw73_64\bin\ repc.exe,根据个人的Qt目录和编译器版本,找个这个repc.exe很容易
在这里插入图片描述
repc.exe的参数都在这里:

Options:
  -?, -h, --help                  Displays help on commandline options.
  --help-all                      Displays help including Qt specific options.
  -v, --version                   Displays version information.
  -i <rep|src>                    Input file type:
                                  rep: replicant template files.
                                  src: C++ QObject derived classes.
  -o <source|replica|merged|rep>  Output file type:
                                  source: generates source header. Is
                                  incompatible with "-i src" option.
                                  replica: generates replica header.
                                  merged: generates combined replica/source
                                  header.
                                  rep: generates replicant template file from
                                  C++ QOject classes. Is not compatible with "-i
                                  rep" option.
  -I <dir>                        Add dir to the include path for header files.
                                  This parameter is needed only if the input
                                  file type is src (.h file).
  -c                              Always output `class` type for .rep files and
                                  never `POD`.
  -d                              Print out parsing debug information (for
                                  troubleshooting).

Arguments:
  [header-file/rep-file]          Input header/rep file to read from, otherwise
                                  stdin.
  [rep-file/header-file]          Output header/rep file to write to, otherwise
                                  stdout.

手动生成rep_XX_replica.h

repc CommonInterface.rep -o replica -c rep_Commoninterface_replica.h

看一眼生成的文件,类名是CommonInterfaceReplica
在这里插入图片描述

手动生成rep_XX_source.h

repc CommonInterface.rep -o source -c rep_Commoninterface_source.h

在这里插入图片描述
在这里插入图片描述
这两文件都手动生成好了,把它们拷贝到Rep文件相同目录中,感觉这个是有些版本的编译的锅,它应该是根据pro或者pri文件帮我们自动生成的,而不是手动生成,这么不方便。

  • 0
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值