How can files and classes be renamed in Qt Creator?

How to rename files and classes (declaration, implementation and use) in Qt Creator 2.0?

I can not find such a function there.

+4
source share
3 answers

There is no such function in Qt Creator :(

This is what you can do:

To rename files:

  • close the project
  • rename files in Windows Explorer or another tool
  • open project
  • update * .pro file, list of * .h files in headers, * .CPP files in sources, * .ui files in forms
  • update all * .ccp files in the #include section to include the corresponding files.

To change the class names, you can use the function Ctrl + Shift + R , which changes the class names in the header and source files.

+3
source

Personally, I needed to do something else.

I renamed my "Form" class to "MainWindow", and I had to go into the "build-yourproject ...- Debug \ ui_mainwindow.h" directory and replace each "form" with "MainWindow" (Ctrl + f), and then he worked.

EDIT: This is a manual solution that modifies the file that is downloaded during each build, so this change is automatically lost. The correct solution is to enter Qt Creator and in the upper right corner under the name "Object", you must have the name of your class, this is what you need to change.

+2
source

If you also want to rename the form and along with your class, you need to edit the file name.ui 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 name.cpp you also need to configure the mUI creation mUI .

mUI(new Ui::NewValueHere)

+1
source

Source: https://habr.com/ru/post/1346413/


All Articles