[Qt-creator] Qt Creator beautifier plugin vs. built-in code style

Eike Ziller Eike.Ziller at qt.io
Tue Aug 22 15:18:19 CEST 2017


> On Aug 22, 2017, at 14:36, Andy <asmaloney at gmail.com> wrote:
> 
> My 2 cents:
> 
> I watched the video (good stuff - thanks!) grabbed clang-format, found this awesome site to create the configuration:
> 
>   https://zed0.co.uk/clang-format-configurator/
> 
> and played with it in Qt Creator.
> 
> Overall I think it's great. I've done some work with Go and I love that go-fmt is run every time I save a file (in Atom). It would be amazing to have that capability with clang-format and Qt Creator.

Options > Beautifier > General > Enable auto format on file save (needs enabled Beautifier plugin)

> The one thing I couldn't get it to do is indent code after accessor keywords. Using "AccessModifierOffset" I can do this:
> 
> {
> public:
>    void foo();
> }
> 
> or this:
> 
> {
>    public:
>    void foo();
> }
> 
> But not the one I want, which is this:
> 
> {
>    public:
>       void foo();
> }
> 
> If anyone has clues on how to accomplish this I'll be a happy humanoid.
> 
> 
> ---
> Andy Maloney  //  https://asmaloney.com
> twitter ~ @asmaloney
> 
> 
> On Tue, Aug 22, 2017 at 3:29 AM, Nikolai Kosjar <nikolai.kosjar at qt.io> wrote:
> On 08/21/2017 08:18 PM, Timur Kristóf wrote:
> Hi,
> 
> I noticed that the built-in code style options somewhat clash with the
> beautifier plugin. (I notice that the code style settings don't affect
> the beautifier plugin at all, and the beautifier settings are rather
> rudimentary at the moment.)
> 
> What are the long-term plans in this regard?
> 
> Do you guys intend to improve the built-in code styling, or do you want
> to eventually replace it with either the beautifier or something based
> on clang-format?
> Evaluation is on-going :)
> 
> I'm playing around with clang-format for the Qt Creator code base to see whether it can replace our built-in code style use cases and how well it can handle our code style/formatting.
> 
> Some general observations:
> 
> 1. Qt Creator has a built-in *indenter*, handling/controlling whitespace before the first token of a line.
> 
> 2. clang-format does this and more:
>  * it handles/controls whitespace everywhere, also taking a maximum column count into account
>  * it can e.g. also sort your includes and add comments at the closing curly brace of namespaces: "} // namespace X".
> 
> 3. The beautifier-plugin for clang-format allows to format the entire file or text selections of it. Changed lines are properly indicated by red vertical stripes in the left editor margin, which is cool. The plugin does not yet make use of the -cursor argument, which allows to format the AST at cursor position and probably would be useful/needed to replace current on-enter-indendation.
> 
> Nikolai
> 
> _______________________________________________
> Qt-creator mailing list
> Qt-creator at qt-project.org
> http://lists.qt-project.org/mailman/listinfo/qt-creator
> 
> _______________________________________________
> Qt-creator mailing list
> Qt-creator at qt-project.org
> http://lists.qt-project.org/mailman/listinfo/qt-creator

-- 
Eike Ziller
Principal Software Engineer

The Qt Company GmbH
Rudower Chaussee 13
D-12489 Berlin
eike.ziller at qt.io
http://qt.io
Geschäftsführer: Mika Pälsi, Juha Varelius, Mika Harjuaho
Sitz der Gesellschaft: Berlin, Registergericht: Amtsgericht Charlottenburg, HRB 144331 B



More information about the Qt-creator mailing list