Auto-generate setters/getters with QTCreator?

2019-02-05 18:05发布

问题:

Despite some searchs, I wasn't able to find a way to auto-generate getters and setters for a C++ class, using QT Creator 2.3.1. Would you guys know some way to do so ?

回答1:

Do a right click on your member then Refactor then Generate Getter and Setter member function and you're done :)


On Qt Creator 3.2.x, create the member, then click on it and press alt+Enter :



回答2:

Position your text cursor at the member variable in class definition, then hit Alt+Enter.



回答3:

For me, right-click, Refactor, Create Getter and Setter member functions works, except when the member is a bool.