Navigate to header in source tree
-
wrote on 6 Jun 2025, 21:05 last edited by Aleksey_K 6 Jun 2025, 21:20
When I press F2 on a class name in a source which uses it QtC navigates me to the header file copied to build dir, not to the original one in the source tree. It is very annoying and leads to errors when I try to edit header copy which will be overwritten on the next build and not the original header. Also F4 on the header copy do not lead me back to the
.cpp
source file or wise versa: F4 from cpp goes to header in build dir, not original one. How to change this behavior? I have cmake project. -
-
wrote 6 days ago last edited by Aleksey_K 8 May 2025, 10:39
Solved by moving build dir out from the source one:
Initial project structure:
+ app ├ src │ ├ build │ │ └ Desktop_Qt_6_8_2-Debug │ └ CMakeLists.txt └ conanfile.py
Current one:
+ app ├ build │ └ Desktop_Qt_6_8_2-Debug ├ src │ └ CMakeLists.txt └ conanfile.py
This move also cleaned up the project tree from
cmake
generated garbage. -
When I press F2 on a class name in a source which uses it QtC navigates me to the header file copied to build dir, not to the original one in the source tree. It is very annoying and leads to errors when I try to edit header copy which will be overwritten on the next build and not the original header. Also F4 on the header copy do not lead me back to the
.cpp
source file or wise versa: F4 from cpp goes to header in build dir, not original one. How to change this behavior? I have cmake project.wrote on 10 Jun 2025, 08:04 last edited byWhy are you copying the header file to the build dir? Usually, this is not necessary.
@Aleksey_K said in Navigate to header in source tree:
navigates me to the header file copied to build dir, not to the original one in the source tree.
Usually, this is because of the order of directories in the include search paths. I am only aware of additional preprocessor defines in QtCreator, but not separate include search paths.
-
Why are you copying the header file to the build dir? Usually, this is not necessary.
@Aleksey_K said in Navigate to header in source tree:
navigates me to the header file copied to build dir, not to the original one in the source tree.
Usually, this is because of the order of directories in the include search paths. I am only aware of additional preprocessor defines in QtCreator, but not separate include search paths.
wrote 6 days ago last edited by@SimonSchroeder said in Navigate to header in source tree:
Why are you copying the header file to the build dir? Usually, this is not necessary.
It is not me but default cmake behavior: https://stackoverflow.com/a/24725634/630169
Inside your build directory, CMake re-creates the whole directory structure of your project.
-
wrote 6 days ago last edited by Aleksey_K 8 May 2025, 10:39
Solved by moving build dir out from the source one:
Initial project structure:
+ app ├ src │ ├ build │ │ └ Desktop_Qt_6_8_2-Debug │ └ CMakeLists.txt └ conanfile.py
Current one:
+ app ├ build │ └ Desktop_Qt_6_8_2-Debug ├ src │ └ CMakeLists.txt └ conanfile.py
This move also cleaned up the project tree from
cmake
generated garbage. -
-