如何使用 qmake 创建 vcproj 使其过滤器反映目录结构? [英] How to create a vcproj with qmake such that its filters reflect the directory structure?

查看:37
本文介绍了如何使用 qmake 创建 vcproj 使其过滤器反映目录结构?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用 qmake (Qt 4.5.1) 创建我的 vcproj 文件.我想为输出 vcproj 创建自定义过滤器,这样不是每个 *.h 文件最终都在头文件"过滤器中,*.cpp 在源文件"等中.

I use qmake (Qt 4.5.1) to create my vcproj files. I would like to create customized filters for the output vcproj, such that not every *.h file ends up in the "Header Files" filter, *.cpp in "Source Files" etc.

例如,包含文件的项目

foo\foo.h
foo\foo.cpp
bar\bar.h
bar\bar.cpp

应该有一个 vcproj 文件

should have a vcproj file with

foo
   foo.h
   foo.cpp
bar
   bar.h
   bar.cpp

代替

Header Files
   bar.h
   bar.cpp
Source Files
   bar.cpp
   foo.cpp

谢谢!

推荐答案

如果您使用 CONFIG -= flat 运行 qmake,您将获得以下项目结构:

If you run qmake with CONFIG -= flat, you'll get the following project structure:

Header Files
    foo
        foo.h
    bar
        bar.h
Source Files
    foo
        foo.cpp
    bar
        bar.cpp

这一直困扰着我,这就是我在 Mac 上为 Xcode 项目编写修复程序的原因.最终我可能会为 VS 编写一个(这更容易,因为项目文件是一个 XML 文档).

This has always bothered me, which is why I'm writing a fix on the Mac for Xcode projects. Eventually I'll probably write one for VS (which is easier since the project file is an XML document).

如果您使用 Visual Studio 在 Windows 上严格编写软件,我建议您使用 Visual Studio 集成插件 因为它会自动生成编译 Qt 文件所需的 UIC 和 MOC 步骤.

If you're writing software strictly on Windows using Visual Studio, I would recommend using the Visual Studio Integration Plugin as it will automatically generate the UIC and MOC steps needed to compile Qt files.

这篇关于如何使用 qmake 创建 vcproj 使其过滤器反映目录结构?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆