[Development] Qt Coding Guidelines

Knoll Lars Lars.Knoll at theqtcompany.com
Fri Mar 18 10:13:13 CET 2016

I’m all for an automated solution for code formatting, so we can remove discussions/comments about wrongly placed braces or spaces from code review and can rather focus more on the content. But there will be still a need for some coding guidelines in other places (like auto usage, foreach and many other things).


On 18/03/16 09:52, "Development on behalf of Sorvig Morten" <development-bounces+lars.knoll=theqtcompany.com at qt-project.org on behalf of Morten.Sorvig at theqtcompany.com> wrote:

>> 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
>Development mailing list
>Development at qt-project.org

More information about the Development mailing list