[Qt-creator] Settings for naming conventions

Nikolai Kosjar nikolai.kosjar at theqtcompany.com
Tue Jan 12 10:19:25 CET 2016

On 01/09/2016 05:28 PM, Jochen Becher wrote:
> Hi,
> I would like to implement naming convention settings for QtCreator. For
> many C++ element identifiers (e.g. namespace, class, attributes,
> methods, getter, setters, boolean getters, local variables etc) the
> user can define a naming convention build from a prefix, a name style
> (e.g. lowerCamelCase, UpperCamelCase etc) and a suffix. This settings
> can be defined globally and per project. A simply API allows fetching
> the base name of an identifier (a list of strings building the middle
> part of the identifier) or converting an identifier from one naming
> convention into another.
> The settings should be used in wizards, refactorings (e.g. create
> setters and getters from attributes) or validating identifiers in text
> editor.

Sounds great!

> I would add the new settings to the cpptools plugin but I am not sure
> about the preferred design:
> 1. I could extend the coding style settings which are connected to the
> TextEditor by design (realization of a codiong style interface) but
> naming conventions are not aligned to the TextEditor in the same manner
> as coding style are.
> 2. I could implement a new settings class which is loosely coupled to
> the cpptools plugin like e.g. the todo plugin settings.
> 3. Or I could implement a new settings class which is strongly coupled
> to the cpptools plugin.
> What do you prefer? Do you have a different preferred design in mind?

Could you elaborate a bit on 2. and 3.? What would be the difference? 
How does "strongly coupled" look like in this case?

The integration into current code style settings as seen by the user in 
the options dialog (Menu: Tools > Options > C++ > Tab: Code Style) and 
the projects mode (Projects Mode: Code Style) seems appropriate. Since 
CppCodeStylePreferences and CppCodeStyleSettings are already exported, I 
don't see a problem enhancing those. This is for C++.

Now, if there is substantial overlap with QML / Qt Quick or other 
languages, this probably should be put somewhere into the text editor 
itself. For instance, we put all the highlighting settings into one 
central place (Options > Text Editor > Fonts & Colors), covering general 
thingies, but also C++ and QML. This corresponds to your first option?


More information about the Qt-creator mailing list