admin管理员组

文章数量:1332865

Is it possible to make Qt Creator to show only project files without their subfolders in the Projects tree view? I'm curious about CMake projects.

Given the following project structure on a disk:

test_project/
├CMakeLists.txt
└src/
 ├test/
 │├test.cpp
 │└test.h
 └main.cpp

Given an excerpt of CMakeLists.txt for anising the project structure in Qt Creator Projects view:

project(proj_tree LANGUAGES CXX)
set(HDR src/test/test.h)
set(SRC src/main.cpp src/test/test.cpp)
source_group("Sources" FILES ${SRC})
source_group("Headers" FILES ${HDR})
add_executable(proj_tree ${SRC} ${HDR})

Here is how Qt Creator displays the project:

proj_tree/
├CMakeLists.txt
└proj_tree/
 ├Headers/
 │└src/
 │ └test/
 │  └test.h
 └Sources/
  └src/
   ├test/
   │└test.cpp
   └main.cpp

What I'd like it to look like:

proj_tree/
├CMakeLists.txt
└proj_tree/
 ├Headers/
 │└test.h
 └Sources/
  ├test.cpp
  └main.cpp

I tried playing with source_group(TREE …), full and relative file paths, using file base names only… But without luck.

P.S.: I've seen this thread which is quite old now (maybe something has changed since then) and not about a CMake project.

本文标签: Hiding Subfolders in Qt Creator Project Tree View for CMake ProjectStack Overflow