How to customize settings for creating getter and setter methods?



  • By default for

    class X
    {
    private:
    	int x_;
    };
    

    We get

    class X
    {
    public:
    	int x() const;
    	void setX(int x);
    	
    private:
    	int x_;
    };
    

    But I would like generating these two methods in another way:

    1. I like when each method starts from the capital letter.
    2. Getter method starts from "Get" word.

    Thanks!


  • Moderators

    The style used is what Qt uses. Unfortunately it is hardcoded so there's no way to change it except by modifying the source and compiling Qt Creator yourself (or just the cppeditor plugin).



  • Check the Qt Creator instructions for snippets.

    I just followed the instructions and modified the auto-completed code for Q_PROPERTY so that the getter follows my company's coding style of "get" + Uppercased property name.

    You can probably create a snippet for what you want.


Log in to reply
 

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