How can I remove files from a QtCreator project
Solution 1
If your project is generated from CMake, the file list is determined by the CMakeLists.txt file, and you cannot add or remove files manually from the source tree in QtCreator. Especially if your CMakeLists file specifies the glob operator for a project's file list, you must manually remove the files from disk and re-run CMake from within QtCreator by going to Build->Run CMake (QtCreator 3.3.0). This will update the file list but also regenerate the project (cbp) file - re-running CMake outside of QtCreator will not update the project file and you will have ghost entries of deleted files showing up in the source tree if you deleted them from disk.
Solution 2
Right-click the file you want to remove, and choose "Remove File..."
Checking the "Delete file permanently" check box will delete the file, otherwise it will just be removed from the project.
![Admin](/assets/logo_square_200-5d0d61d6853298bd2a4fe063103715b4daf2819fc21225efa21dfb93e61952ea.png)
Admin
Updated on October 16, 2022Comments
-
Admin over 1 year
Might be a very newbie question, but I can't find a way to remove files from my projects in QtCreator. Thanks!
-
Dennis about 14 yearsAh didn't find it either, you have to delete the files and not the folders.
-
lawlove about 10 yearsThat apparently just temporarily removes the project from the startup page - at least for the CMakeLists.txt case. The CMakeCache.txt also had entries for the project name but even after deleting those, it re-created the project name so it reappeared on the start page
-
lawlove about 10 yearsAhh - because that's the project name in CMakeLists.txt ; so any time I selected CMakeLists.txt to create a new project it gives it that name.
-
Daniel Saner over 9 yearsThanks! Deleting the build directory is definitely necessary when using MSVC2010. I was wondering why it was still looking for files no longer mentioned anywhere in the project.
-
Harvey over 9 yearsThis is not what the original post was asking for. (But it was what I was looking for - thanks.)
-
Andy about 9 yearsAnd if "Remove File..." is disabled?
-
Markus Meskanen almost 8 yearsThe question is, why doesn't Qt creator do this automatically?
-
flatline almost 8 yearsI'm pretty sure I don't want Qt creator changing my cmake code behind the scenes, so deleting the file from the filesystem is at best going to be a half-measure that doesn't really achieve the objective. Some notification to this effect would be helpful though.
-
Josh about 7 yearsBe warned that this option still deletes files (at least on Windows) even if you have the box unchecked. It's not in my recycle bin either.
-
vlz over 4 yearsThe
Remove File...
option might be disabled, because the file is from a different project AND that project is not ocrrectly configured. In that case it should be contained in a project folder higher up in the tree. You can right-click that folder and chooseClose project "project name"
. -
Joules about 2 yearshad this issue, doing it manually fixed my project tree