Clang format and code beautifier for Qt Creator

Different developers use different styles with different IDE (i.e some people use space, some use tab) which may cause lots of change in your git repository. One solution to this is to use some standard code formatting and beautifier. clang is a great tool for this purpose and can be easily integrated with git hooks and IDE.
First, install it by:

now if you have a file like this:

after running the following:

now you can use it like:

Available styles are LLVM, Google, Chromium, Mozilla, WebKit.

You can config clang for Qt Creator:

go to Tools>Option then:

And then go to the Environment>keyboard and set your shortcut:

This is what I get after pressing shift+s:

 

Leave a Reply

avatar
  Subscribe  
Notify of