Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Auto-generate setter/getter limitation
Forum Updated to NodeBB v4.3 + New Features

Auto-generate setter/getter limitation

Scheduled Pinned Locked Moved Unsolved General and Desktop
4 Posts 4 Posters 1.2k 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.
  • I Offline
    I Offline
    iraytrace79
    wrote on last edited by
    #1

    It seems that QtCreator's "generate setter/getter" only works if your member variables start with an underscore or nothing special, not if they use the m_NAME convention. Since this has been a common naming convention, it sure would be nice this was a recognized pattern. Is there an option someplace I haven't set that would allow this? We have a code base that uses this naming convention.

    1 Reply Last reply
    0
    • VRoninV Offline
      VRoninV Offline
      VRonin
      wrote on last edited by
      #2

      Strange, it works for me. Qt creator 4.0.3 on windows. I'm using the pre-build binary

      "La mort n'est rien, mais vivre vaincu et sans gloire, c'est mourir tous les jours"
      ~Napoleon Bonaparte

      On a crusade to banish setIndexWidget() from the holy land of Qt

      kshegunovK 1 Reply Last reply
      2
      • VRoninV VRonin

        Strange, it works for me. Qt creator 4.0.3 on windows. I'm using the pre-build binary

        kshegunovK Offline
        kshegunovK Offline
        kshegunov
        Moderators
        wrote on last edited by
        #3

        @VRonin
        Works for me on Linux as well (same version).

        Read and abide by the Qt Code of Conduct

        1 Reply Last reply
        3
        • H Offline
          H Offline
          herlarbee
          wrote on last edited by
          #4

          I understand what you mean . Whenever you append the "m_" to your class variable names. It automatically skips the "m_" appended and just gives a setter and getter name without the "m_".
          This is the default behaviour of Qt Creator. To change this compile Qt Creator from source and in the file tagged /plugins/cppeditor/cppquickfixes.cpp search for the method
          void GenerateGetterSetterOperation::determineGetterSetterNames()
          ( You should consider lines 5963 - 5983 and tweak to suit your needs.)

          I personally have not needed this but since you do. I believe this is what you should do
          To study the library for reference before manipulation consider
          https://github.com/qtproject/qt-creator/blob/master/src/plugins/cppeditor/cppquickfixes.cpp

          Marked as solved if this helps you

          1 Reply Last reply
          3

          • Login

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