Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Qt Creator and other tools
  4. Qt Creator C++ Indentation Problems
Qt 6.11 is out! See what's new in the release blog

Qt Creator C++ Indentation Problems

Scheduled Pinned Locked Moved Solved Qt Creator and other tools
3 Posts 2 Posters 901 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • KenAppleby 0K Offline
    KenAppleby 0K Offline
    KenAppleby 0
    wrote on last edited by
    #1

    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.

    1 Reply Last reply
    0
    • sierdzioS Offline
      sierdzioS Offline
      sierdzio
      Moderators
      wrote on last edited by
      #2

      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.

      (Z(:^

      1 Reply Last reply
      0
      • KenAppleby 0K Offline
        KenAppleby 0K Offline
        KenAppleby 0
        wrote on last edited by
        #3

        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".

        1 Reply Last reply
        1
        • KenAppleby 0K KenAppleby 0 has marked this topic as solved on

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved