Qt Codestyle Automatic Check

Code style carries many benefits, such as improved maintainability and support for a rich Coding Standard. However it’s not safe to rely on developers to always comply to style rules along the source code, that’s why automatic code style verification should be an initial concern for professional-level works.

For the sake of coding-style-importance-aware people, there are many great projects such as GNU indent, pep8 and astyle that perform all the work for you, whose only need the appropriate setup flags.

For Qt projects, astyle is the recommended tool. But there are a few drawbacks on using it.

  • it’s too intrusive. astyle performs code modification in-line, disturbing the repository sources instead of serving as a verification tool only
  • weak didactic factor. Unlike pep8 script, which tells the developer exactly what the problem is and contributes to avoid it at the future (as a lesson learned effect)
  • it’s output can not be easily integrated with another tools

I’ve created a shell script in order to overcome some of the previous issues. It’s available here. Some relevant features.

  • quickfix-style list output
  • QTest style output at the end
  • Ignore moc created files
  • All suggested modifications can be applied as one patch, directly available to the user
  • Can be run inside a testsuite (make test) or as a standalone program


  • try to extend astyle classes
  • allow alternative code styles
  • better source selection schema (integrated with qmake, maybe?)
  • fix-up improper indentation on some important macros (foreach, .e.g.)
  • test and make it work on MacOS

Tags: , , , , , , ,


  1. Hello, after reading this remarkable paragraph i am too delighted to share my know-how here with colleagues.

  2. We have been a bunch of volunteers and also starting off a new design in your neighborhood. Your website provided us with practical info to figure for. You may have conducted the challenging action plus your overall area will probably be gracious to you personally.

  3. I savour, cause I discovered exactly what I used to be looking for.
    You’ve ended my 4 day lengthy hunt! God Bless you man. Have a great day. Bye

    Here is my blog; foreigner loan

  4. Greetings! Quick question that’s totally off topic. Do you know how to make your site mobile friendly? My site looks weird when browsing from my apple iphone. I’m trying to find a theme or plugin that might be able to fix this problem.
    If you have any suggestions, please share. With thanks!

  5. Kenneth Christiansen

    Would be nice to add the additional coding style guidelines from the WebKit project, and a flag for which ones of the guidelines have precedence

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code class="" title="" data-url=""> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre class="" title="" data-url=""> <span class="" title="" data-url="">