aboutsummaryrefslogtreecommitdiffstats
path: root/doc/qtcreator/src/projects/creator-only/creator-projects-settings-code-style.qdoc
blob: 88e0354aaa960f8a012e021930ac4e1e192769fc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
// Copyright (C) 2024 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only

// **********************************************************************
// NOTE: the sections are not ordered by their logical order to avoid
// reshuffling the file each time the index order changes (i.e., often).
// Run the fixnavi.pl script to adjust the links to the index order.
// **********************************************************************

/*!
    \page creator-code-style-settings.html
    \previouspage creator-how-tos.html

    \ingroup creator-how-to-configure-editors

    \title Specify code style

    The MIME type of the file determines which mode
    and editor the file opens in. \QC opens C++ files in \uicontrol Edit mode
    in the C++ code editor and QML files in the Qt Quick editor.

    Specify indentation for:

    \list
        \li C++ files
        \li QML files
        \li Nim files
    \endlist

    Specify code style either globally or separately for each project.
    You can specify several sets of code style settings and easily switch between
    them. In addition, you can import and export code style settings.

    To override the global code style for the current project:

    \list 1

        \li Go to \uicontrol Projects > \uicontrol {Project Settings} >
            \uicontrol {Code Style}.

            \image qtcreator-code-style-clang-format-project.webp {Code Style settings in Projects mode}

        \li In \uicontrol Language, select \uicontrol C++,
            \uicontrol {Qt Quick}, or \uicontrol Nim.

        \li For C++, clear \uicontrol {Use global settings} to use the
            \c {.clang-format} file for the project.

        \li To override the project's \c {.clang-format} file,
            select \uicontrol {Use custom settings}.

        \li In \uicontrol {Custom settings}, select the settings to use for the
            project.
    \endlist

    In rare cases, ClangFormat can trip over a code construct and
    trigger a \QC crash. If that happens for your project, select
    \uicontrol {Use Built-In Indenter} in \uicontrol {Formatting mode} to
    turn off ClangFormat for the project. If you can reproduce the crash,
    go to \uicontrol Help > \uicontrol {Report Bug} to report
    the bug and attach the code that triggers the crash to the bug report.

    \sa {Indent text or code}, {Edit MIME types}, {C++ Code Style},
    {Qt Quick Code Style}, {Nim}
*/