[Development] Qt Coding Guidelines

Sorvig Morten Morten.Sorvig at theqtcompany.com
Fri Mar 18 09:52:50 CET 2016

> On 18 Mar 2016, at 08:48, Jędrzej Nowacki <jedrzej.nowacki at theqtcompany.com> wrote:
> So I think, that we should not discuss what is better qdoc or md. The real 
> discussion is about tooling, what is the best tool to sanitize Qt code. We 
> need something that:
> 1. Can work as a sanity bot
> 2. Can re-format the code by applying changes (git hook?)
> 3. Rules are easy to express and they can be exported (qdoc, html, fooBar)
> 4. Works on diff level (so it doesn't complain about the whole world being 
> broken)
> Bonus:
> 5. C++, js, qml awareness

I’ve used clang-format on wip/nacl, with the following workflow:

<edit files>
git add
<review changes>
git commit

Where git-clang-format looks at staged content only, and does not touch files 
with unstaged changes.

This would allow us to incrementally adopt it on a per-commit, per-developer
basis. As a matter of policy, “I ran clang-format!” should then be an acceptable
response to style remarks on gerrit. (within reason)


Qt-like .clang.format: http://code.qt.io/cgit/qt/qtbase.git/tree/src/plugins/platforms/pepper/.clang-format?h=wip/nacl
git-clang-format script: https://llvm.org/svn/llvm-project/cfe/trunk/tools/clang-format/git-clang-format

More information about the Development mailing list