Auto-generate setter/getter limitation



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



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


  • Qt Champions 2016

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



  • 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


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.