简体   繁体   English

如何强制Qt Visual Studio加载项更新自定义生成步骤以创建MOC文件

[英]How to Force Qt Visual Studio Add-in to Update Custom Build Steps to Create MOC Files

I'm dealing with a situation where I need to convert a number of Visual Studio files from a home-grown solution for processing resource, UI files, and creating MOC files from includes to using the Qt Visual Studio add-in. 我正在处理一种情况,我需要从本地解决方案转换许多Visual Studio文件,以处理资源,UI文件,以及从包含到使用Qt Visual Studio加载项创建MOC文件。 Unfortunately, the only way I could figure out to force the add-in to correctly process the files is to remove them and add them back. 不幸的是,我想出办法强制加载项正确处理文件的唯一方法是删除它们,然后将它们重新添加。 That's easier said than done, especially since this is a legacy system and some directories have multiple applications in the folder. 说起来容易做起来难,尤其是因为这是一个旧系统,并且某些目录在文件夹中有多个应用程序。 I can't just remove all includes and add them back; 我不能只是删除所有包含项并将其添加回去; I have to filter the ones that are appropriate. 我必须过滤合适的那些。 It's also made more difficult when the project uses folders to organize because then I have to remove the include files from a folder and add only those back to that folder and proceed to the next. 当项目使用文件夹进行组织时,这也变得更加困难,因为然后我必须从文件夹中删除包含文件,然后仅将那些文件添加回该文件夹并继续下一个操作。 I searched for answers on this, and the only thing I found was a similar 5-year-old question on the Qt form that no one ever answered. 我在此寻找答案,我发现的唯一发现是在Qt表格上有一个类似的已有5年历史的问题,没人能回答。

I don't have a solution for .qrc and .ui files, but for generating MOC files from include files, I found that the following works. 我没有.qrc和.ui文件的解决方案,但是从包含文件生成MOC文件时,我发现以下工作有效。

  1. Use mass Find/Replace to change all Q_OBJECT macros to something unique; 使用批量查找/替换将所有Q_OBJECT宏更改为唯一的内容; I used TCEJBO_Q. 我使用了TCEJBO_Q。
  2. Save all changed files. 保存所有更改的文件。
  3. Use mass Find/Replace to restore the macros back to Q_OJBECT. 使用批量查找/替换将宏还原回Q_OJBECT。
  4. Save all changed files. 保存所有更改的文件。 At this point, the add-in will kick in and generate the build steps to create MOC files. 此时,加载项将启动并生成用于创建MOC文件的构建步骤。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM