C/C++, IDE, Programming

Qt – Cross-platform software development

Download

Beautifying Source Code

  • Download Artistic Style
  • Extract astyle to e.g. Documents
  • Open qt creator
  • Goto Help -> About Plugins -> C++ -> Load Beautifier
  • Restart qt creator
  • Goto Tools -> Options… -> Beautifier -> General -> Check “Enable auto format on file save” and “Restrict to files contained in the current project“. Make sure that Artistic Style is selected as default Tool.
  • Goto Artistic Style Tab -> set Artistic Style command, e.g.
    C:\Users\myusername\Documents\AStyle_2.06_windows\AStyle\bin\AStyle.exe
  • Goto Artistic Style Tab -> select “Use file *.astylerc defined in project files
  • Click Add button to your style.
  • Name it e.g. “mystyle”.
  • Copy paste the following style into Value textbox:
--style=google
--indent=force-tab=4
--indent-switches
--indent-namespaces
--indent-preprocessor
--indent-col1-comments
--pad-oper
--pad-header
--align-pointer=name
--verbose
--lineend=windows
--suffix=none
  • Click OK.
  • Select “Use customized style” and select your style.
  • Click OK.

Beautifying Source Code Keyboard shortcut

  • Goto Tools -> Options… -> Environment -> Keyboard -> find ArtisticStyle (FormatFile)
  • Record a new key sequence e.g. Ctrl+E, Ctrl+D (Visual Studio shortcut).

Note
Create an empty file %APPDATA%\QtProject\qtcreator\beautifier\documentation\artisticstyle.xml if you get an error about artisticstyle.xml missing.