Qt Creator 16 set clang format version
-
Hi,
Is it possible to use a custom clang-format executable in Qt Creator and not the built in version? The current Qt Creator ships with version 19 something.
But on our build machine there is a different clang format version and despite using the same .clang-format file the formatting result sometimes differs for different clang format versions.
I would like to fix the clang format version to something independent of qt creator. Is that possible?
Other llvm executables like clangd can easily be customized.. -
You can probably achieve that by installing the Beautifier plugin.
Under Preferences->Beautifier, you can then specify a clang-format executable. -
Thanks, I need to try if that really picks the correct version in the editor. I find it a bit confusing, because there seem to be at least two different options for using clang format in Qt creator.
- There is a "ClangFormat" extension which lets me do auto formatting of the code, but without having the possibility to choose another than the built-in version of clang-format. It is configurable under Preferences->C++->Code Style.
- Having activated the Beautifier plugin I can set a specific version under Preferences->Beautifier->ClangFormat.
But it seems I can have both plugins active at the same time and then I don't know what happens.
I have disabled the ClangFormat extension for now (which is enabled by default) and enabled only the beautifier plugin. Will report here how it goes.
-
So, with the beautifier we made it work now. In the end we had to remove
LineEnding: CRLF
From our .clang-format file, since this was breaking completely the formatting in Qt Creator. Running clang format from the command line worked fine though.
The ClangFormat extension does not apply the formatting on the full file, but only on changed lines, which we did not want. Also it made the settings dialog of Qt Creator extremely slow somehow.
-