C++ 如何在 QtCreator 中更改项目名称?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/6873936/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to change a project's name in QtCreator?
提问by sunset
Is there a way to change a .pro , .ui and .h names if the project is done? How to do it?
如果项目完成,有没有办法更改 .pro 、 .ui 和 .h 名称?怎么做?
采纳答案by gnud
Names for .ui
, .h
and .cpp
files can just be changed inside Qt Creator.
名字.ui
,.h
和.cpp
文件可以只是Qt Creator的内部变化。
The name of the .pro
file is a bit more involved. The simplest is probably to copy the project, rename the .pro
file, and reopen.
.pro
文件名有点复杂。最简单的可能是复制项目,重命名.pro
文件,然后重新打开。
Qt Creator also uses its own config file, .pro.user
, for changes you do in the project and build settings. You can just delete the .pro.user
-file, and it'll generate a new one. If you've made changes to the settings and the build process, you can rename that file as well, but remember to read through it and check build paths etc.
Qt Creator 还使用其自己的配置文件 ,.pro.user
用于您在项目和构建设置中所做的更改。你可以删除.pro.user
-file,它会生成一个新的。如果您对设置和构建过程进行了更改,您也可以重命名该文件,但请记住通读它并检查构建路径等。
Edit by anonymous: Run qmake to generate a new Makefile with updated references to the project name
匿名编辑:运行 qmake 以生成一个新的 Makefile,其中包含对项目名称的更新引用
回答by iammilind
- Open the terminal or folder structure where the current project is stored; e.g. in Linux you may right click on .pro file and "open in terminal"
- Close the Qt creator completely
- Rename the containing folder also to
new_name
- Rename the
old_name.pro
tonew_name.pro
- Inside the
new_name.pro
, rename theTARGET = new_name
- You may delete the debug & release folders of
old_name
project which were stored in parallel to theold_name
folder - Restart the Qt creator; Open the project
new_name.pro
- 打开存放当前项目的终端或文件夹结构;例如在 Linux 中,您可以右键单击 .pro 文件并“在终端中打开”
- 完全关闭 Qt Creator
- 将包含的文件夹也重命名为
new_name
- 重命名
old_name.pro
为new_name.pro
- 在 中
new_name.pro
,重命名TARGET = new_name
- 您可以删除与文件夹
old_name
并行存储的项目的调试和发布文件old_name
夹 - 重启Qt创建器;打开项目
new_name.pro
This answer is inspired from this answer.
这个答案的灵感来自这个答案。
回答by Tebe
go to folder there is your project
转到文件夹,那里是您的项目
cp current_name.pro new_name.pro && rm current_name.pro
cp current_name.pro new_name.pro && rm current_name.pro
qt will show you warning message , ignore
qt 会显示警告信息,忽略
with qt(open project) reopen your folder, open new_name.pro
使用 qt(打开项目)重新打开您的文件夹,打开 new_name.pro