[SOLVED] Rename class in Qt Creator



  • Hello friends.

    I want to rename some class in Qt Creator. Of course, I expect the IDE to rename *h and *cpp files, everything within these files, every #include with this class and so on. It is an easy operation in Eclipse for example, but I can not find how to do this in Qt Creator.

    Thanks!



  • Hi.
    Just right click on needed name and follow Refactor - > Rename Symbol Under Cursor
    or just press Ctrl+Shift+R



  • qxoz, thank you for your reply!
    Ok, it renames all occurrences of selected text in the project. But it is not enough, I want IDE to rename class files too!
    Example:
    I have files keystroke.h and keystroke.cpp. They contain class KeyStroke. I rename class to KeyStroke1. And I expect IDE to rename keystroke.h -> keystroke1.h and keystroke.cpp -> keystroke1.cpp.



  • Well, unfortunately i didn't find such option in QtCreator.
    I have changed the file names and "#include" lines manually.


  • Moderators

    You can:

    Rename the file by right-clicking it in the Project tree on the left (or press F2), and then

    Press Ctrl+Shift+F to replace "keystroke.h" with "keystroke1.h" everywhere in your code

    If you want the feature you described, you can suggest it at https://bugreports.qt-project.org/



  • [quote author="JKSH" date="1377776503"]

    Rename the file by right-clicking it in the Project tree on the left (or press F2), and then

    Press Ctrl+Shift+F to replace "keystroke.h" with "keystroke1.h" everywhere in your code

    [/quote]
    I was referring to these actions, when I said manually :)


  • Moderators

    [quote author="qxoz" date="1377777293"]I was referring to these actions, when I said manually :)[/quote]Ok :) It's good to be detailed, nonetheless -- I only discovered Ctrl+Shift+F from this forum several weeks ago!



  • [quote author="JKSH" date="1377777532"]It's good to be detailed, [/quote]
    yes you are right :)



  • [quote author="JKSH" date="1377776503"]You can:

    Rename the file by right-clicking it in the Project tree on the left (or press F2), and then

    Press Ctrl+Shift+F to replace "keystroke.h" with "keystroke1.h" everywhere in your code

    [/quote]
    Update:

    1. Fix

    @
    #ifndef KEYSTROKE_H
    #define KEYSTROKE_H
    @

    to
    @
    #ifndef KEYSTROKE1_H
    #define KEYSTROKE1_H
    @

    1. Find and replace all #include "keystroke.h" to #include "keystroke1.h"

    A hell of work!

    [quote author="JKSH" date="1377776503"]
    If you want the feature you described, you can suggest it at https://bugreports.qt-project.org/[/quote]

    I'll try.

    Ok, the question may be regarded as SOLVED, although it is not what I expected.

    Thanks guys!


  • Moderators

    [quote author="QtYury" date="1377785295"]4. Find and replace all #include "keystroke.h" to #include "keystroke1.h"

    A hell of work![/quote]Did you click "Search & Replace" after Ctrl+Shift+F? That should be fast.



  • [quote author="JKSH" date="1377787647"][quote author="QtYury" date="1377785295"]4. Find and replace all #include "keystroke.h" to #include "keystroke1.h"

    A hell of work![/quote]Did you click "Search & Replace" after Ctrl+Shift+F? That should be fast.[/quote]

    Sure, its fast. I'm just upset that it's four consecutive operations instead of one.


  • Moderators

    Sorry, but renaming files is not that straight forward when supporting several build systems -- especially considering that none of those was intended to be used from within an IDE. :-/



  • Why is this topic closed? Wouldn't it be great if Qt Creator could do like https://www.jetbrains.com/help/idea/15.0/rename-refactorings.html ?


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.