Uploaded image for project: 'Qt Creator'
  1. Qt Creator
  2. QTCREATORBUG-1924 Add code-generating quick-fixes.
  3. QTCREATORBUG-1532

Feature request for auto-implementation methods of defined class and auto create Q_PROPERTY by member

    XMLWordPrintable

Details

    • 5b5ae971045adebe40209150cf9e1cac6cc62191 (qt-creator/qt-creator/master)

    Description

      It would be nice add feature for auto-implementation of defined class. For example we have a class:

      Object class difinition
      class Object : public QObject
      {
          Q_OBJECT
      public:
          explicit Object(QObject* parent = 0);
          ~Object();
          void foo();
      
      private:
          void bar() const;
          int m_variable;
      };
      
      

      If we are clicked RMB on "class Object" we must see menu with options like:

      • Class auto-implementation
        • Create implementation for class methods in .cpp file
        • Create implementation for class methods in header
        • Create implementation for class methods in header separate from class difinition

      There is result of "Create implementation for class methods in .cpp file"

      *.cpp file
      Object::Object(QObject* parent = 0) : QObject(parent) /*auto-created stub*/
      {
      }
      
      Object::~Object() /*auto-created stub*/
      {
      }
      
      void Object::foo() /*already created NOTHING DO*/
      {
      }
      
      void Object::bar() const /*auto-created stub*/
      {
      }
      

      There is result of "Create implementation for class methods in header"

      *.h file
      class Object : public QObject
      {
          Q_OBJECT
      public:
          explicit Object(QObject* parent = 0) : QObject(parent) {}
          ~Object() {}
          void foo() {}
      
      private:
          void bar() const {}
          int m_variable;
      };
      

      There is result of "Create implementation for class methods in header separate from class difinition"

      *.h file
      class Object : public QObject
      {
          Q_OBJECT
      public:
          explicit Object(QObject* parent = 0);
          ~Object();
          void foo();
      
      private:
          void bar() const;
          int m_variable;
      };
      
      Object::Object(QObject* parent = 0) : QObject(parent) /*auto-created stub*/
      {
      }
      
      Object::~Object() /*auto-created stub*/
      {
      }
      
      void Object::foo() /*already created NOTHING DO*/
      {
      }
      
      void Object::bar() const /*auto-created stub*/
      {
      }
      

      Also we would auto-create stubs for Q_PROPERTY macros. User click on class variable and select menu action like:

      • Meta-Object system
        • Create stubs for member: "m_variable"

      And our class seeing like this:

      *.h file
      class Object : public QObject
      {
          Q_OBJECT
          Q_PROPERTY(int variable READ variable WRITE setVariable) /*auto-created stub*/
      public:
          explicit Object(QObject* parent = 0);
          ~Object();
          void foo();
          int variable() const {return m_variable;} /*auto-created stub*/
          void setVariable(int variable) {m_variable = variable;} /*auto-created stub*/
      
      private:
          void bar() const;
          int m_variable;
      };
      

      Discussion on QtDN

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            davschul David Schulz
            sabrog Vladislav
            Votes:
            47 Vote for this issue
            Watchers:
            32 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes