c/c++语言开发共享Qt Remote Object(QtRO)解决找不到rep_xx_source.h或rep_xx_replica.h的终极方法

手动生成rep_xx_source.h或rep_xx_replica.h的方法repc命令的位置和参数手动生成rep_XX_replica.h手动生成rep_XX_source.h在用的时候,发现一些问题,我的Qt Creator版本是5.14.1,在使用Qt Remote Object(QtRO),发现几个影响rep_xx_source.h或rep_xx_replica.h生成的问题。关于.rep书写的格式,参照官方文档:Qt Remote Objects CompilerREPC_REPLICA

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

    • repc命令的位置和参数
    • 手动生成rep_XX_replica.h
    • 手动生成rep_XX_source.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:QtQt5.14.15.14.1mingw73_64bin repc.exe,根据个人的Qt目录和编译器版本,找个这个repc.exe很容易
Qt Remote Object(QtRO)解决找不到rep_xx_source.h或rep_xx_replica.h的终极方法
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
Qt Remote Object(QtRO)解决找不到rep_xx_source.h或rep_xx_replica.h的终极方法

手动生成rep_XX_source.h

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

Qt Remote Object(QtRO)解决找不到rep_xx_source.h或rep_xx_replica.h的终极方法
Qt Remote Object(QtRO)解决找不到rep_xx_source.h或rep_xx_replica.h的终极方法
这两文件都手动生成好了,把它们拷贝到Rep文件相同目录中,感觉这个是有些版本的编译的锅,它应该是根据pro或者pri文件帮我们自动生成的,而不是手动生成,这么不方便。

c/c++开发分享Qt Remote Object(QtRO)解决找不到rep_xx_source.h或rep_xx_replica.h的终极方法地址:https://blog.csdn.net/hp_cpp/article/details/107252649

本文来自网络收集,不代表计算机技术网立场,如涉及侵权请联系管理员删除。

ctvol管理联系方式QQ:251552304

本文章地址:https://www.ctvol.com/c-cdevelopment/599156.html

(0)
上一篇 2021年5月9日
下一篇 2021年5月9日

精彩推荐