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. Tweaking code refactoring options in Qt Creator
Forum Updated to NodeBB v4.3 + New Features

Tweaking code refactoring options in Qt Creator

Scheduled Pinned Locked Moved Unsolved Qt Creator and other tools
6 Posts 3 Posters 1.8k Views 4 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.
  • R Offline
    R Offline
    Robert Hairgrove
    wrote on last edited by Robert Hairgrove
    #1

    When writing C++ code, it's very cool to add a member function in a class header file and have Qt Creator automagically add the stub in the .cpp file for you (right-click on the function name, choose "Refactor" and then choose the option from the context menu).

    Is it possible to tweak some of that functionality, for example to add a comment such as "// TO DO..." to the function body, or stubs for functions that return values? I have looked for any configuration files that might have the templates, but so far haven't had any luck. Or is this compiled in with the sources?

    1 Reply Last reply
    0
    • mrjjM Offline
      mrjjM Offline
      mrjj
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi
      I was also interested tweaking it but it seems
      its not accessible from outside. ( in any config files I could find)

      So most likely its compiled into creator via some qrc file.
      I might have missed it, so you could go looking in the source. :)

      1 Reply Last reply
      3
      • Pradeep KumarP Offline
        Pradeep KumarP Offline
        Pradeep Kumar
        wrote on last edited by
        #3

        Hi,

        Welcome to Forum

        are you looking like this similar

        /**

        • @brief ClassName::func
          */

        type /** and then click enter.
        u will get like the above one.

        void ClassName::void func()
        {
        // func body
        }

        Pradeep Kumar
        Qt,QML Developer

        1 Reply Last reply
        2
        • Pradeep KumarP Offline
          Pradeep KumarP Offline
          Pradeep Kumar
          wrote on last edited by
          #4

          For the function u can type expicitly using

          void ClassName::void func()
          {
          /*
          *
          *
          * func() Body commenting part for the repective function.
          *
          */

                        // func body
          

          }

          as above , you can type.

          Thanks,

          Pradeep Kumar
          Qt,QML Developer

          R 1 Reply Last reply
          2
          • Pradeep KumarP Pradeep Kumar

            For the function u can type expicitly using

            void ClassName::void func()
            {
            /*
            *
            *
            * func() Body commenting part for the repective function.
            *
            */

                          // func body
            

            }

            as above , you can type.

            Thanks,

            R Offline
            R Offline
            Robert Hairgrove
            wrote on last edited by Robert Hairgrove
            #5

            @Pradeep-Kumar ... thanks for the suggestions. But it's not just about (Doxygen) comments, I know about those, too. I am also thinking about this situation:

            // in file.hpp:
            class foo {
              bool init();
            // etc. 
            };
            

            Then I get this in the .cpp file as default implementation when I refactor it:

            bool foo::init()
            {
            
            }
            

            What would be nice is to have a template which would generate this instead:

            bool foo::init() 
            {
                bool retval = true;
                // TO DO...
                return retval;
            }
            

            (of course, only if there was some trivial return type such as bool, int, or double).
            At least that way I don't forget to return something... it would even compile without warnings to that effect. OTOH it might be useful NOT to provide a default implementation so that if I forgot to implement something, the compiler would tell me... YMMV

            1 Reply Last reply
            1
            • Pradeep KumarP Offline
              Pradeep KumarP Offline
              Pradeep Kumar
              wrote on last edited by
              #6

              @Robert-Hairgrove

              Honestly i have never tried that.
              As mentioned by @mrjj should look into the source.

              Pradeep Kumar
              Qt,QML Developer

              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