简体   繁体   English

使用 Qt 加载项在 Visual Studio 中为 moc_* 预编译 header

[英]Precompiled header for moc_* in Visual Studio with Qt add-in

I try to make moc.exe to add a precompiled header include into generated moc_* files in Visual Studio with Qt plugin.我尝试使用 Qt 插件使 moc.exe 添加预编译的 header 包含到 Visual Studio 中生成的 moc_* 文件中。

I tried to add a PRECOMPILED_HEADER=myheader.h (also with quotes) line into project's preprocessor definitions, that didn't work.我尝试在项目的预处理器定义中添加 PRECOMPILED_HEADER=myheader.h (也带有引号)行,但没有成功。

I also tried to add -DPRECOMPILED_HEADER=myheader.h as a parameter for moc.exe in the project *.vcxproj file.我还尝试在项目 *.vcxproj 文件中添加 -DPRECOMPILED_HEADER=myheader.h 作为 moc.exe 的参数。

Can anyone help?任何人都可以帮忙吗?

Open Qt project settings (from context menu of vcxproj in VS) there you'll have moc options , in there you can use something like: -b stdafx.h打开Qt project settings (来自 VS 中 vcxproj 的上下文菜单),你将有moc options ,在那里你可以使用类似: -b stdafx.h

Note in VS2019 the integration changed and you have the Qt options integrated into the default options dialog, there you have Qt Meta-Object Compiler and an Force Include option, here you should not need the -b flag (but, you'll need to test that if this is the case).请注意,在 VS2019 中,集成发生了变化,您将 Qt 选项集成到默认选项对话框中,您有Qt Meta-Object CompilerForce Include选项,这里您不需要-b标志(但是,您需要测试是否是这种情况)。 For more info you can check the documentation here .有关更多信息,您可以在此处查看文档。

Adding -fstdafx.h -f../%(Identity) to the moc.exe command line works for me.-fstdafx.h -f../%(Identity)添加到 moc.exe 命令行对我有用。

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

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