Qt Creator C++ Indentation Problems
-
Qt 6.7.1; QtCreator 14.0.1 on Windows 10
Hi,
In order to fix a breakage when running Android apps after a Qt upgrade, I have recently cleared out Qt caches in AppData/Local and AppData/Roaming, as well as removing the original build directories.This fixed the problem but I am left with Qt default formatting options for the C++ code, which I really can't use. I want to customise code indentation, specifically to indent all blocks with 4 spaces. So:
namespace foo { namespace bar { class Baz { }; } }instead of
namespace foo { namespace bar { class Baz { }; } }and so on, with TAB meaning "indent leading whitespace only" and without ther aggressive auto-formatting enabled.
There are several more options I would like to set, but these are the main ones.I just can't find any way to set Edit->Preferences->C++->Code Style to do this.
I have struggled with this in the past and somehow managed to find an acceptable solution, but one evades me now.
Any help with this would be greatly appreciated. -
I think you need to first copy an existing preset and then it will allow you to modify it.
In Qt Creator 14 you can also select different preset per-project. When you have a project open, look in Projects->Code Style.
-
Thanks, yes, I have copied the preset. It was the hunt through the various properties I was failing at.
The one I need is "NamespaceIndentation", unsurprisingly, but I was assuming the value it took was the number of spaces. It should be the string "All". -
K KenAppleby 0 has marked this topic as solved on