I wonder if there is a way to have a view of the project tree, showing subdirectories. In our project, we have many different classes that are each in a different directory. Being able to get those subdirectories to show would be useful to find the file we want to edit.
方法: I'm using .pri file in each subdirectory instead of .pro.
[Your main .pro file]
TEMPLATE = app
include(foo/foo.pri)
SOURCES += main.cpp \ ...
DEPENDPATH += foo [not sure, it is necessary] 可以不用
INCLUDEPATH += foo [not sure, it is necessary] 可以不用
[foo.pri]
HEADERS += $$PWD/foo.h
SOURCES += $$PWD/foo.cpp
注: $$PWD/必须要用, 否则是显示不出目录结构的, 这个在Windows, Mac下都能起作用, 想必在Linux也同样有效.
什么是.pri文件呢?
Thanks for the hint, but what exactly are .pri files, I often see them
around, but I haven't found anywhere in the documentation where they are
mentioned. Is there a place I can learn about them?
It's just a naming convention for junks of .pro files that are supposed
to be included using 'include(...)' in 'real' .pro files, 'real' meaning
'having a TARGET=... line'.
.pri文件其实就是把.pro文件的后缀改成.pri, .pro文件中使用include(xxx/xxx.pri)和有TARGET=xzy这两行.
The .pri file contains the list of source files, header files, .ui files, and .qrc files in the project. Developers on platforms other than Windows can add or remove files to the project by editing the .pri file.