How to customize settings for creating getter and setter methods?
Solved
Qt Creator and other tools
-
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:
- I like when each method starts from the capital letter.
- Getter method starts from "Get" word.
Thanks!
-
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.