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. Auto adding definition and mutator method
Forum Updated to NodeBB v4.3 + New Features

Auto adding definition and mutator method

Scheduled Pinned Locked Moved Qt Creator and other tools
25 Posts 4 Posters 14.7k Views 1 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.
  • S Offline
    S Offline
    Schneidi
    wrote on last edited by
    #1

    Hi,

    I was wondering if there is any way in the Creator to auto add the definition of methods in the .cpp, when I declare
    the prototype in the .h or auto add getter and setter methods when I declare a member variable.

    This features are a great improvement, but I'm still missing them in the Creator.

    I would be happy if there is a way to get this features.
    Thanks for the information.

    1 Reply Last reply
    0
    • A Offline
      A Offline
      andre
      wrote on last edited by
      #2

      I believe there is a Qt Creator plugin for that, but I am not quite sure.

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

        I am not sure when this was introduced (before 2.1 feature freeze or afterwards): Add a method to a .h file, move cursor on the method name and hit Alt-Enter.

        Not really obvious, I agree. The refactoring indicator is still missing in C++ files.

        I am not aware about anything for the getter/setter methods though.

        1 Reply Last reply
        0
        • A Offline
          A Offline
          andre
          wrote on last edited by
          #4

          Works in my 2.1.0 RC, so I guess it was before ;-)

          Good to know! I would have expected this to appear in the context menu for the declaration though, instead of the Switch Between Method Declaration/Definition item if there is no definition yet.

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

            Andre: But then it would be too obvious:-)

            Technically it is a C++ Quick Fix operation and we trigger those by Alt-Enter. There are more (like make a char array translatable, turn one into a QLatin1String, etc.), but as I said before: The indication when those can be triggered are still missing... which would make this really nice feature way more useful since people actually have a chance to find it.

            1 Reply Last reply
            0
            • S Offline
              S Offline
              Schneidi
              wrote on last edited by
              #6

              Ok thanks Tobias, this was pretty helpful and I guess I should have to get on it by myself.
              But yes it isn't really obvious ; )

              I'm wondering if there is no one else missing the auto add of getter and setter methods because they took much time.

              I would be really interessted in that kind of helpers.

              1 Reply Last reply
              0
              • A Offline
                A Offline
                andre
                wrote on last edited by
                #7

                I do miss automatic generation of getter and setter method, but I would like to see them being auto-generated by the Q_PROPERTY macro.

                1 Reply Last reply
                0
                • S Offline
                  S Offline
                  Schneidi
                  wrote on last edited by
                  #8

                  Thats a nice idea, as far as i can affect the behavior of these methods.

                  1 Reply Last reply
                  0
                  • A Offline
                    A Offline
                    andre
                    wrote on last edited by
                    #9

                    [quote author="Schneidi" date="1299866850"]Thats a nice idea, as far as i can affect the behavior of these methods.[/quote]

                    Obviously. I was thinking about something like this:
                    @
                    //not actual code, just an idea
                    Q_PROPERTY (QString myString READ myString MEMBER m_myString GENERATED_WRITE setMyString GENERATED_NOTIFY myStringChanged)
                    @

                    The idea is that you specify the member variable to use, and that the macro can generate the getter, setter and/or the signal by using a different keyword than the standard READ and WRITE. In this case, the read method would not be generated, but the write and the signal would be.

                    1 Reply Last reply
                    0
                    • S Offline
                      S Offline
                      Schneidi
                      wrote on last edited by
                      #10

                      Ok, but this approach would generate the most basic kind of getter and setter methods right ?
                      This is a nice way to save much time for basic member access.

                      IMHO it would be enough to generate the mutator methods. If I want to add more logic to these methods i guess that would be a good and easy to maintain approach.

                      Other IDEs already offer these features. The Creator is a fantastic piece of software but there are some nice features missing yet.

                      1 Reply Last reply
                      0
                      • A Offline
                        A Offline
                        andre
                        wrote on last edited by
                        #11

                        Yes, that is the idea. I guess having QtCreator generate the methods would already be a big help, but having them generated by Q_PROPERTY would be more maintainable. Deleting the Q_PROPERTY also gets rid of the generated methods that way.

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

                          You guys are developers, so I am looking forward to your Merge Requests about those helpers;-)

                          Seriously: It is not that hard to write them, using the existing examples as a guide. http://qt.gitorious.org/qt-creator/qt-creator/blobs/master/src/plugins/cppeditor/cppquickfixes.cpp has most of the code of the existing ones.

                          1 Reply Last reply
                          0
                          • A Offline
                            A Offline
                            andre
                            wrote on last edited by
                            #13

                            I just might... But first, I am going to see how a previous merge request is going to fare. I know it is my turn now for that request, but I have seen others stalled for about a year. Thanks for the ALT-Enter tip though!

                            1 Reply Last reply
                            0
                            • S Offline
                              S Offline
                              Schneidi
                              wrote on last edited by
                              #14

                              Believe it or not,

                              I take this into consideration, but if there is already such a plug-in or whatever why should I do another.
                              But at the moment my skills arn't at the level to write plug-ins for the creator.

                              Maybe in the near future ^^

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

                                Andre: We try to process MRs as fast as possible, but sometimes they do stall:-( The people doing the reviews are the developers that work on creator. Unfortunately we all are rather swamped with work... We try to keep up, but some MRs fall through the cracks, others are reviewed but awaiting action by the submitters. Gitorious does not send notification on updates to MRs, so sending a mail to the reviewer does help getting your MRs through the review faster.

                                Feel free to send me a message if you feel your MR did not get the attention it deserved. I'm happy to poke my coworkers;-)

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

                                  Schneidi: Quickfixes should just be a couple of lines of code, no need to put those into a separate plugin.

                                  1 Reply Last reply
                                  0
                                  • A Offline
                                    A Offline
                                    andre
                                    wrote on last edited by
                                    #17

                                    Tobias, I understand that you do, and I wasn't talking about Creator either but about Qt proper. Perhaps the smaller group working on Creator is a bit more agile and processes merge requests faster. I have no experience with that. I hope the situation will improve for Qt itself too with the implementation of the Open Governance strategy.

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

                                      Andre: Our track record in Qt Creator is unfortunately not perfect, either:-(

                                      All of us here hope to see open governance asap! It will make things so much easier for us!

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

                                        Good news: Just noticed that Qt Creator 2.2 will have support to implement getters and setters based in a Q_PROPERTY.

                                        We still have a few too many bugs open against the 2.2 branch to release a Qt Creator 2.2 beta, but we are working on those right now.

                                        1 Reply Last reply
                                        0
                                        • A Offline
                                          A Offline
                                          andre
                                          wrote on last edited by
                                          #20

                                          [quote]Good news: Just noticed that Qt Creator 2.2 will have support to implement getters and setters based in a Q_PROPERTY.[/quote]
                                          Nice!
                                          Thanks! Is that something added just now by you because of this thread? ;)

                                          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