如何从QtCreator项目中删除文件

时间:2023-01-13 20:46:19

Might be a very newbie question, but I can't find a way to remove files from my projects in QtCreator. Thanks!

可能是一个非常新手的问题,但我找不到从QtCreator中的项目中删除文件的方法。谢谢!

7 个解决方案

#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.

如果您的项目是从CMake生成的,则文件列表由CMakeLists.txt文件确定,您无法在QtCreator中从源树手动添加或删除文件。特别是如果您的CMakeLists文件为项目的文件列表指定了glob操作符,则必须手动从磁盘中删除文件,并通过转到Build-> Run CMake(QtCreator 3.3.0)从QtCreator中重新运行CMake。这将更新文件列表,但也会重新生成项目(cbp)文件 - 重新运行QtCreator外部的CMake不会更新项目文件,如果从磁盘中删除它们,您将在源树中显示已删除文件的重影条目。

#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.

选中“永久删除文件”复选框将删除该文件,否则它将从项目中删除。

#3


Could not find one-touch action as in Eclipse to delete a class:

无法在Eclipse中找到删除类的单触操作:

1) Press right click on the file/class, and then choose "remove file..."; (u can tick "permanently" to remove from HDD if you like).

1)按右键单击文件/类,然后选择“删除文件...”; (如果您愿意,可以“永久”勾选从HDD中删除)。

2) Do it to .CPP and .H files.

2)对.CPP和.H文件执行此操作。

3) Then check in your .pro file the class are not there anymore.

3)然后检查你的.pro文件,该类不再存在。

Note: Some compilers will keep searching for this file/class in compilation. Just delete the compilation directory and compile again.

注意:某些编译器将继续在编译中搜索此文件/类。只需删除编译目录并再次编译即可。

#4


If you mess up like me and accidentally add a lot of files to the qml.qrc, it might help to know that these are listed in the actual qml.qrc file which you can edit to remove these files.

如果你像我一样陷入困境并且不小心将大量文件添加到qml.qrc中,那么可能有助于知道这些文件列在实际的qml.qrc文件中,您可以编辑它们以删除这些文件。

#5


  1. Find your project file .pro in qt creator or other text editor
  2. 在qt creator或其他文本编辑器中找到您的项目文件.pro

  3. Find the file/folder name you want to remove in the .pro file
  4. 在.pro文件中找到要删除的文件/文件夹名称

  5. Delete all the files you want to remove
  6. 删除要删除的所有文件

  7. save and close the project
  8. 保存并关闭项目

  9. Reload the project
  10. 重新加载项目

  11. DONE

#6


go directly delete the project folder from your hdd.

直接从你的硬盘中删除项目文件夹。

#7


For Linux, edit ~/.config/QtProject/QtCreator.ini

对于Linux,请编辑〜/ .config / QtProject / QtCreator.ini

Under [ProjectExplorer], delete the project name and its corresponding configuration file from the following two lists:

在[ProjectExplorer]下,从以下两个列表中删除项目名称及其相应的配置文件:

RecentProjects\DisplayNames
RecentProjects\FileNames

e.g., given the following
RecentProjects\DisplayNames=proj1, proj2, proj3
RecentProjects\FileNames=<proj1_dir>/CMakeLists.txt, <proj2_dir>/proj2.pro, <proj3_dir>/proj3.pro

例如,给定以下RecentProjects \ DisplayNames = proj1,proj2,proj3 RecentProjects \ FileNames = /CMakeLists.txt, /proj2.pro, /proj3.pro

to delete proj1 from the qtcreator startup page, edit the above two lists as

要从qtcreator启动页面删除proj1,请将以上两个列表编辑为

RecentProjects\DisplayNames=proj2, proj3
RecentProjects\FileNames=<proj2_dir>/proj2.pro, <proj3_dir>/proj3.pro

RecentProjects \ DisplayNames = proj2,proj3 RecentProjects \ FileNames = /proj2.pro, /proj3.pro

#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.

如果您的项目是从CMake生成的,则文件列表由CMakeLists.txt文件确定,您无法在QtCreator中从源树手动添加或删除文件。特别是如果您的CMakeLists文件为项目的文件列表指定了glob操作符,则必须手动从磁盘中删除文件,并通过转到Build-> Run CMake(QtCreator 3.3.0)从QtCreator中重新运行CMake。这将更新文件列表,但也会重新生成项目(cbp)文件 - 重新运行QtCreator外部的CMake不会更新项目文件,如果从磁盘中删除它们,您将在源树中显示已删除文件的重影条目。

#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.

选中“永久删除文件”复选框将删除该文件,否则它将从项目中删除。

#3


Could not find one-touch action as in Eclipse to delete a class:

无法在Eclipse中找到删除类的单触操作:

1) Press right click on the file/class, and then choose "remove file..."; (u can tick "permanently" to remove from HDD if you like).

1)按右键单击文件/类,然后选择“删除文件...”; (如果您愿意,可以“永久”勾选从HDD中删除)。

2) Do it to .CPP and .H files.

2)对.CPP和.H文件执行此操作。

3) Then check in your .pro file the class are not there anymore.

3)然后检查你的.pro文件,该类不再存在。

Note: Some compilers will keep searching for this file/class in compilation. Just delete the compilation directory and compile again.

注意:某些编译器将继续在编译中搜索此文件/类。只需删除编译目录并再次编译即可。

#4


If you mess up like me and accidentally add a lot of files to the qml.qrc, it might help to know that these are listed in the actual qml.qrc file which you can edit to remove these files.

如果你像我一样陷入困境并且不小心将大量文件添加到qml.qrc中,那么可能有助于知道这些文件列在实际的qml.qrc文件中,您可以编辑它们以删除这些文件。

#5


  1. Find your project file .pro in qt creator or other text editor
  2. 在qt creator或其他文本编辑器中找到您的项目文件.pro

  3. Find the file/folder name you want to remove in the .pro file
  4. 在.pro文件中找到要删除的文件/文件夹名称

  5. Delete all the files you want to remove
  6. 删除要删除的所有文件

  7. save and close the project
  8. 保存并关闭项目

  9. Reload the project
  10. 重新加载项目

  11. DONE

#6


go directly delete the project folder from your hdd.

直接从你的硬盘中删除项目文件夹。

#7


For Linux, edit ~/.config/QtProject/QtCreator.ini

对于Linux,请编辑〜/ .config / QtProject / QtCreator.ini

Under [ProjectExplorer], delete the project name and its corresponding configuration file from the following two lists:

在[ProjectExplorer]下,从以下两个列表中删除项目名称及其相应的配置文件:

RecentProjects\DisplayNames
RecentProjects\FileNames

e.g., given the following
RecentProjects\DisplayNames=proj1, proj2, proj3
RecentProjects\FileNames=<proj1_dir>/CMakeLists.txt, <proj2_dir>/proj2.pro, <proj3_dir>/proj3.pro

例如,给定以下RecentProjects \ DisplayNames = proj1,proj2,proj3 RecentProjects \ FileNames = /CMakeLists.txt, /proj2.pro, /proj3.pro

to delete proj1 from the qtcreator startup page, edit the above two lists as

要从qtcreator启动页面删除proj1,请将以上两个列表编辑为

RecentProjects\DisplayNames=proj2, proj3
RecentProjects\FileNames=<proj2_dir>/proj2.pro, <proj3_dir>/proj3.pro

RecentProjects \ DisplayNames = proj2,proj3 RecentProjects \ FileNames = /proj2.pro, /proj3.pro