How can files and classes be renamed in Qt Creator?
How do I rename files and classes (declaration, impleme开发者_开发技巧ntation and uses) in Qt Creator 2.0?
I can't find such feature in there.
There is no such feature in Qt Creator :(
This is what you can do:
To rename files:
- close your project
- rename files in Windows Explorer or some other tool
- open project
- update *.pro file, list *.h files in headers, *.CPP files in sources, *.ui files in forms
- update all *.ccp files in the #include section to include proper files
To change class names you can use the Ctrl + Shift + R feature that changes class names in header files and source files.
If you also want to rename a form and along with its class, you have to edit your name.ui
file and change the widget name
and class
to the new corresponding value.
You also need to rename some things in your name.h
file.
namespace Ui {
class NewValueHere;
}
private:
Ui::NewValueHere* mUI;
In your name.cpp
file you also have to adjust the call of creating your mUI
.
mUI(new Ui::NewValueHere)
Personnally I needed to do something more.
I renamed my class "Form" to "MainWindow", and I had to go in the directory "build-yourproject...-Debug\ui_mainwindow.h" and replace every "Form" with "MainWindow" (Ctrl+f) and then it worked.
EDIT: This was a manual solution that changes a file that is re-loaded at every build, so this change is automatically lost. The right solution is to go in Qt Creator and in the upper-right corner, under the name "Object", you should have the name of your class, that is what you need to change.
精彩评论