Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Qt Creator and other tools
  4. [SOLVED] Rename class in Qt Creator
Forum Updated to NodeBB v4.3 + New Features

[SOLVED] Rename class in Qt Creator

Scheduled Pinned Locked Moved Qt Creator and other tools
13 Posts 5 Posters 16.8k Views 2 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • Q Offline
    Q Offline
    QtYury
    wrote on last edited by
    #1

    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!

    1 Reply Last reply
    0
    • Q Offline
      Q Offline
      qxoz
      wrote on last edited by
      #2

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

      1 Reply Last reply
      1
      • Q Offline
        Q Offline
        QtYury
        wrote on last edited by
        #3

        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.

        1 Reply Last reply
        0
        • Q Offline
          Q Offline
          qxoz
          wrote on last edited by
          #4

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

          1 Reply Last reply
          0
          • JKSHJ Offline
            JKSHJ Offline
            JKSH
            Moderators
            wrote on last edited by
            #5

            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/

            Qt Doc Search for browsers: forum.qt.io/topic/35616/web-browser-extension-for-improved-doc-searches

            1 Reply Last reply
            0
            • Q Offline
              Q Offline
              qxoz
              wrote on last edited by
              #6

              [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 :)

              1 Reply Last reply
              0
              • JKSHJ Offline
                JKSHJ Offline
                JKSH
                Moderators
                wrote on last edited by
                #7

                [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!

                Qt Doc Search for browsers: forum.qt.io/topic/35616/web-browser-extension-for-improved-doc-searches

                1 Reply Last reply
                0
                • Q Offline
                  Q Offline
                  qxoz
                  wrote on last edited by
                  #8

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

                  1 Reply Last reply
                  0
                  • Q Offline
                    Q Offline
                    QtYury
                    wrote on last edited by
                    #9

                    [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!

                    1 Reply Last reply
                    0
                    • JKSHJ Offline
                      JKSHJ Offline
                      JKSH
                      Moderators
                      wrote on last edited by
                      #10

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

                      Qt Doc Search for browsers: forum.qt.io/topic/35616/web-browser-extension-for-improved-doc-searches

                      1 Reply Last reply
                      0
                      • Q Offline
                        Q Offline
                        QtYury
                        wrote on last edited by
                        #11

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

                        1 Reply Last reply
                        0
                        • T Offline
                          T Offline
                          tobias.hunger
                          wrote on last edited by
                          #12

                          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. :-/

                          1 Reply Last reply
                          0
                          • H Offline
                            H Offline
                            Haponov
                            wrote on last edited by
                            #13

                            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 ?

                            1 Reply Last reply
                            0

                            • Login

                            • Login or register to search.
                            • First post
                              Last post
                            0
                            • Categories
                            • Recent
                            • Tags
                            • Popular
                            • Users
                            • Groups
                            • Search
                            • Get Qt Extensions
                            • Unsolved