ΡΠΎΡΠΌΠ°ΡΠΈΡΠΎΠ²Π°Π½ΠΈΠ΅ ΠΊΠΎΠ΄Π° qt creator
Qt Coding Style
ΠΡΠΈΠ²Π΅Ρ, Ρ
Π°Π±ΡΠ°ΠΆΠΈΡΠ΅Π»ΠΈ!
Π‘Π΅ΠΉΡΠ°Ρ ΠΊΠ°ΠΊΠΎΠΉ-ΡΠΎ ΡΠΏΠ΅Ρ Ρ ΠΌΠ½ΠΎΠ³ΠΎΠ»Π΅ΡΠ½ΠΈΠΌ ΠΎΠΏΡΡΠΎΠΌ ΡΠ°Π±ΠΎΡΡ Ρ Qt ΠΏΠΎΠ΄ΡΠΌΠ°Π»: Β«Π§ΡΠΎ Π·Π° ΡΠΈΠ³Π½Ρ? Π₯Π°Π±Ρ β Π΄Π»Ρ Π²Π΅ΡΠ΅ΠΉ ΠΏΠΎΠΊΡΡΡΠ΅!Β». ΠΠΎ Π²Π΅Π΄Ρ Π΄Π°ΠΆΠ΅ ΡΠΏΠ΅ΡΠ°ΠΌ Ρ ΠΌΠ½ΠΎΠ³ΠΎΠ»Π΅ΡΠ½ΠΈΠΌ ΠΎΠΏΡΡΠΎΠΌ ΠΈΠ½ΠΎΠ³Π΄Π° Π½Π°Π΄ΠΎ ΡΠΈΡΠ°ΡΡ Π²ΠΎΡ ΡΠ°ΠΊΠΈΠ΅ ΡΡΠ°ΡΡΠΈ ΠΏΡΠΎ ΠΏΡΠΎΡΡΡΠ΅ Π²Π΅ΡΠΈ, Π²Π΅Π΄Ρ ΡΡΠΎ β Π²Π°ΠΆΠ½ΠΎ. ΠΠΎΠ΄ β ΡΡΠΎ ΠΎΠ΄Π½Π° ΠΈΠ· ΡΠ°ΠΌΡΡ Π²Π°ΠΆΠ½ΡΡ ΡΠΎΡΡΠ°Π²Π»ΡΡΡΠΈΡ ΠΏΡΠΎΠ³ΡΠ°ΠΌΠΌΠΈΡΠΎΠ²Π°Π½ΠΈΡ. Π Π½Π°ΡΠ° Π·Π°Π΄Π°ΡΠ° β Π΄Π΅ΡΠΆΠ°ΡΡ Π΅Π³ΠΎ Π² ΡΠΈΡΡΠΎΡΠ΅. ΠΡΠ° ΡΡΠ°ΡΡΡ ΠΏΠΎΡΠ²ΡΡΠ΅Π½Π° Π²ΡΠ΅ΠΌ Qt ΠΏΡΠΎΠ³ΡΠ°ΠΌΠΌΠΈΡΡΠ°ΠΌ ΠΊΠΎΡΠΎΡΡΠ΅ ΡΡΡΠ΅ΠΌΡΡΡΡ ΠΊ ΠΈΠ΄Π΅Π°Π»Ρ.
ΠΠΎΠ½Π΅ΡΠ½ΠΎ Π΅ΡΡΡ ΡΡΠ°ΡΡΡ Π½Π° Qt Project β Qt Coding Style. Π’ΠΎΠ»ΡΠΊΠΎ Π²ΠΎΡ ΡΠ°ΠΌ ΠΌΠ°ΡΠ΅ΡΠΈΠ°Π»Π° ΡΠ΅Π½Π½ΠΎΠ³ΠΎ ΠΌΠ΅Π½ΡΡΠ΅β¦
ΠΠΎΡΡΡΠ»Π°Ρ β1. ΠΡΡΠ°Π²Π½ΠΈΠ²Π°Π½ΠΈΠ΅
Π Qt ΠΏΡΠΈΠ½ΡΡΠΎ ΠΈΡΠΏΠΎΠ»ΡΠ·ΠΎΠ²Π°ΡΡ ΠΎΡΡΡΡΠΏΡ ΠΏΠΎ 4 ΠΏΡΠΎΠ±Π΅Π»Π°. ΠΠΎ ΠΈΠΌΠ΅Π½Π½ΠΎ 4, ΠΈ ΠΈΠΌΠ΅Π½Π½ΠΎ ΠΏΡΠΎΠ±Π΅Π»Π°. ΠΡΠΏΠΎΠ»ΡΠ·ΠΎΠ²Π°ΡΡ \t ΠΈΠ»ΠΈ Π΄ΡΡΠ³ΡΡ ΡΠΈΡΠΈΠ½Ρ ΠΏΡΠΎΠ±Π΅Π»ΠΎΠ² ΡΡΠΈΡΠ°Π΅ΡΡΡ ΡΠΆΠ°ΡΠ½ΠΎ ΠΏΠ»ΠΎΡ
ΠΈΠΌ ΡΠΎΠ½ΠΎΠΌ ΠΈ ΠΆΠ΅ΡΡΠΎΠΊΠΎ ΠΊΠ°ΡΠ°Π΅ΡΡΡ.
ΠΠΎΡΡΡΠ»Π°Ρ β2. ΠΠ±ΡΡΠ²Π»Π΅Π½ΠΈΠ΅ ΠΏΠ΅ΡΠ΅ΠΌΠ΅Π½Π½ΡΡ
ΠΠ΄ΠΈΠ½ ΠΈΠ· ΡΠ°ΠΌΡΡ Π²Π°ΠΆΠ½ΡΡ ΠΏΠΎΡΡΡΠ»Π°ΡΠΎΠ², ΡΠ°ΠΊ ΠΊΠ°ΠΊ ΠΎΠΏΡΠ΅Π΄Π΅Π»ΡΠ΅Ρ ΡΠΈΡΠ°Π±Π΅Π»ΡΠ½ΠΎΡΡΡ ΠΈ ΠΎΠ±ΡΠΈΠΉ ΡΡΠΈΠ»Ρ ΠΊΠΎΠ΄Π°. ΠΡΠ°Π²ΠΈΠ»Π° ΠΎΠ±ΡΡΠ²Π»Π΅Π½ΠΈΡ ΠΏΠ΅ΡΠ΅ΠΌΠ΅Π½Π½ΡΡ ΡΠΎΠ±ΡΠ°Π½Ρ Π² ΡΠ°ΠΊΠΎΠΉ ΡΠΏΠΈΡΠΎΠΊ:
ΠΠΎΡΡΡΠ»Π°Ρ β3. ΠΡΠΎΠ±Π΅Π»Ρ
ΠΡΠΎΠ±Π΅Π»Ρ β ΠΎΡΠ΅Π½Ρ Π²Π°ΠΆΠ½ΡΠΉ ΡΠ»Π΅ΠΌΠ΅Π½Ρ ΡΠΎΡΠΌΠ°ΡΠΈΡΠΎΠ²Π°Π½ΠΈΡ ΠΈΡΡ ΠΎΠ΄Π½ΠΎΠ³ΠΎ ΠΊΠΎΠ΄Π°. ΠΠ½ ΠΎΡΡΠ³ΡΡΠ²Π°Π΅Ρ ΠΎΡΠ΅Π½Ρ Π±ΠΎΠ»ΡΡΡΡ ΡΠΎΠ»Ρ Π² ΡΠΈΡΠ°Π±Π΅Π»ΡΠ½ΠΎΡΡΠΈ ΠΊΠΎΠ΄Π°.
ΠΠΎΡΡΡΠ»Π°Ρ β4. Π‘ΠΊΠΎΠ±ΠΊΠΈ
Π‘ΠΊΠΎΠ±ΠΊΠΈ β ΡΡΠΎ Π²ΠΎΠΎΠ±ΡΠ΅ ΠΎΡΠ΄Π΅Π»ΡΠ½Π°Ρ ΡΠ΅ΠΌΠ°. ΠΠ½ΠΈ, ΠΊΠ°ΠΊ ΠΈ ΠΏΡΠΎΠ±Π΅Π»Ρ, ΠΎΡΡΠ³ΡΡΠ²Π°ΡΡ Π»ΡΠ²ΠΈΠ½ΡΡ Π΄ΠΎΠ»Ρ Π²ΠΎ Π²Π½Π΅ΡΠ½Π΅ΠΌ Π²ΠΈΠ΄Π΅ ΠΈ ΡΠΈΡΠ°Π±Π΅Π»ΡΠ½ΠΎΡΡΠΈ ΠΊΠΎΠ΄Π°
ΠΠΎΡΡΡΠ»Π°Ρ β5. ΠΡΡΠ³Π»ΡΠ΅ ΡΠΊΠΎΠ±ΠΊΠΈ
ΠΡΠΏΠΎΠ»ΡΠ·ΡΠΉΡΠ΅ ΠΊΡΡΠ³Π»ΡΠ΅ ΡΠΊΠΎΠ±ΠΊΠΈ ΡΡΠΎΠ±Ρ Π³ΡΡΠΏΠΏΠΈΡΠΎΠ²Π°ΡΡ Π²ΡΡΠ°ΠΆΠ΅Π½ΠΈΡ:
ΠΠΎΡΡΡΠ»Π°Ρ β6. Π£ΡΠ»ΠΎΠ²ΠΈΡ ΠΌΠ½ΠΎΠΆΠ΅ΡΡΠ²Π΅Π½Π½ΠΎΠ³ΠΎ Π²ΡΠ±ΠΎΡΠ° switch
ΠΠ΅Π·ΡΡΠ»ΠΎΠ²Π½ΠΎ, ΡΡΠΈ ΡΡΠ»ΠΎΠ²ΠΈΡ ΠΏΡΠΈΡΠΈΠ½Π° ΠΌΠ½ΠΎΠ³ΠΈΡ Π΄ΠΈΡΠΊΡΡΡΠΈΠΉ ΡΠΎ ΡΡΠΎΡΠΎΠ½Ρ ΡΠ°Π·ΡΠ°Π±ΠΎΡΡΠΈΠΊΠΎΠ² ΠΈ ΡΠΎΠ·Π΄Π°ΡΠ΅Π»Π΅ΠΉ Coding Guidelines β ΡΠ°ΠΌ ΠΌΠΎΠΆΠ΅Ρ Π±ΡΡΡ ΠΎΡΠ΅Π½Ρ ΠΌΠ½ΠΎΠ³ΠΎ ΡΠ°Π·Π»ΠΈΡΠ½ΡΡ Π²Π°ΡΠΈΠ°Π½ΡΠΎΠ². ΠΠ΄Π½Π°ΠΊΠΎ Qt ΠΏΡΠ΅Π΄Π»Π°Π³Π°Π΅Ρ ΠΈΠΌΠ΅Π½Π½ΠΎ ΡΠ°ΠΊΠΎΠΉ Π²Π°ΡΠΈΠ°Π½Ρ:
ΠΠΎΡΡΡΠ»Π°Ρ β7. Π Π°Π·ΡΡΠ² ΡΡΡΠΎΠΊ
Π§Π°ΡΡΠΎ ΠΏΡΠΎΠΈΡΡ ΠΎΠ΄ΠΈΡ ΡΠ»Π΅Π΄ΡΡΡΠ΅Π΅: Π΅ΡΡΡ ΡΠ°Π·ΡΠ°Π±ΠΎΡΡΠΈΠΊ ΠΠ°ΡΡ Ρ Π±ΠΎΠ»ΡΡΠΈΠΌ ΠΌΠΎΠ½ΠΈΡΠΎΡΠΎΠΌ. ΠΠ½ ΠΏΠΈΡΠ΅Ρ ΡΠ΅Π±Π΅ ΠΊΠΎΠ΄ ΡΠΏΠΎΠΊΠΎΠΉΠ½ΠΎ. ΠΠΎΡΠΎΠΌ ΡΡΠΎΡ ΠΊΠΎΠ΄ ΠΎΡΠΊΡΡΠ²Π°Π΅Ρ ΡΠ°Π·ΡΠ°Π±ΠΎΡΡΠΈΠΊ ΠΠ΅ΡΡ, Ρ Π½ΠΎΡΡΠ±ΡΠΊΠΎΠΌ, ΠΈ ΠΏΡΠΎΠ·ΡΠ΅Π²Π°Π΅Ρ β Π΅ΠΌΡ ΠΏΡΠΈΡ ΠΎΠ΄ΠΈΡΡΡ ΠΌΠ½ΠΎΠ³ΠΎ ΡΠΊΡΠΎΠ»Π»ΠΈΡΡ ΡΡΠΎΠ±Ρ ΠΏΡΠΎΡΠΈΡΠ°ΡΡ Π²Π΅ΡΡ ΠΊΠΎΠ΄. ΠΡΠΎ ΠΎΠ΄ΠΈΠ½ ΠΈΠ· Π΄Π΅ΡΠ΅ΠΊΡΠΎΠ² ΡΠΈΡΠ°Π±Π΅Π»ΡΠ½ΠΎΡΡΠΈ. Π§ΡΠΎ ΠΆΠ΅ ΠΏΡΠ΅Π΄Π»Π°Π³Π°Π΅Ρ Qt Π΄Π»Ρ ΡΠΏΠ°ΡΠ΅Π½ΠΈΡ?
UPD: ΠΏΠΎΡΠ»Π΅Π΄Π½ΠΈΠΉ ΡΡΠ°ΡΡΠΎΠΊ ΠΊΠΎΠ΄Π° ΠΎΡΠΎΠ±ΡΠ°ΠΆΠ°Π΅ΡΡΡ Π½Π΅Π²Π΅ΡΠ½ΠΎΠ΅ β ΡΠ°ΠΌ Π²ΡΠ΅ ΡΡΡΠΎΡΠΊΠΈ Π΄ΠΎΠ»ΠΆΠ½Ρ Π±ΡΡΡ Π½Π° ΠΎΠ΄Π½ΠΎΠΌ ΡΡΠΎΠ²Π½Π΅
ΠΠΎΡΡΡΠ»Π°Ρ β8. ΠΠ°ΡΠ»Π΅Π΄ΠΎΠ²Π°Π½ΠΈΠ΅ ΠΈ ΠΊΠ»ΡΡΠ΅Π²ΠΎΠ΅ ΡΠ»ΠΎΠ²ΠΎ `virtual`
ΠΠΎΡΡΡΠ»Π°Ρ β9. ΠΠ±ΡΠ΅Π΅ ΠΈΡΠΊΠ»ΡΡΠ΅Π½ΠΈΠ΅
ΠΡΠΎΡ ΠΏΠΎΡΡΡΠ»Π°Ρ Π³Π»Π°ΡΠΈΡ Π½Π°ΠΌ, ΡΡΠΎ Π½Π΅Ρ Π½ΠΈΡΠ΅Π³ΠΎ ΠΏΠ»ΠΎΡ ΠΎΠ³ΠΎ Π΅ΡΠ»ΠΈ Π²Ρ Π½Π°ΡΡΡΠΈΡΠ΅ ΠΊΠ°ΠΊΠΎΠ΅-ΡΠΎ ΠΏΡΠ°Π²ΠΈΠ»ΠΎ, Π½ΠΎ ΡΠΎΠ»ΡΠΊΠΎ Π² ΡΠΎΠΌ ΡΠ»ΡΡΠ°Π΅, Π΅ΡΠ»ΠΈ ΠΎΠ½ΠΎ Π΄Π΅Π»Π°Π΅Ρ Π²Π°Ρ ΠΊΠΎΠ΄ ΡΡΠΎΠ΄Π»ΠΈΠ²ΡΠΌ. ΠΡΠΎ Ρ ΠΎΡΠΎΡΠΈΠΉ ΠΏΡΠΈΠΌΠ΅Ρ ΡΠΎΠ³ΠΎ, ΡΡΠΎ Ρ Π²ΡΠ΅Ρ ΠΏΡΠ°Π²ΠΈΠ» Π΅ΡΡΡ ΠΈΡΠΊΠ»ΡΡΠ΅Π½ΠΈΡ, ΠΈ ΡΠΎΠ³ΠΎ, ΡΡΠΎ ΠΏΡΠ°Π²ΠΈΠ»Π° ΡΠΎΠ·Π΄Π°Π½Ρ ΡΡΠΎΠ±Ρ ΠΈΡ Π½Π°ΡΡΡΠ°ΡΡ.
Π ΡΠΎΠΆΠ°Π»Π΅Π½ΠΈΡ, Ρ Π½Π΅ ΡΠΌΠΎΠ³ Π½Π°ΠΉΡΠΈ ΠΏΡΠΈΠΌΠ΅ΡΠ°, ΠΊΠΎΠ³Π΄Π° Qt Coding Guidelines Π΄Π΅Π»Π°ΡΡ ΠΊΠΎΠ΄ β ΡΡΠΎΠ΄Π»ΠΈΠ²ΡΠΌ.
ΠΠ°Π²Π΅ΡΡΠ΅Π½ΠΈΠ΅
ΠΠΎΡΡΡ ΡΡΠΎ ΡΡΠΎ ΠΊΠΎΠ½Π΅Ρ ΠΌΠΎΠ΅ΠΉ ΡΡΠ°ΡΡΠΈ ΠΏΡΠΎ ΡΡΠΈΠ»Ρ Π½Π°ΠΏΠΈΡΠ°Π½ΠΈΡ ΠΊΠΎΠ΄Π° Π² Qt. ΠΡΠ΅ ΡΠ°Π· Π½Π°ΠΏΠΎΠΌΠ½Ρ ΡΡΠΎ ΡΠΎΠ»ΡΠΊΠΎ ΠΎΠ½ ΠΊΠΎΡΠΈΡΡΠ΅ΡΡΡ Π΄Π»Ρ ΠΊΠΎΠ½ΡΡΠΈΠ±ΡΡΡΠΈΠ½Π³Π° Π² Qt, ΡΠ°ΠΊ ΡΡΠΎ Π΅ΡΠ»ΠΈ Π²Ρ ΡΠΎΠ±ΠΈΡΠ°Π΅ΡΠ΅ΡΡ Π²Π½Π΅ΡΡΠΈ ΡΠ²ΠΎΡ Π»Π΅ΠΏΡΡ Π² ΡΠ°Π·Π²ΠΈΡΠΈΠ΅ ΠΏΡΠΎΠ΅ΠΊΡΠ°, Π²Π°ΠΌ ΡΠ°ΠΊ ΠΈΠ»ΠΈ ΠΈΠ½Π°ΡΠ΅ ΠΏΡΠΈΠ΄Π΅ΡΡΡ ΠΈΡΠΏΠΎΠ»ΡΠ·ΠΎΠ²Π°ΡΡ ΡΡΠΈ ΠΏΠΎΡΡΡΠ»Π°ΡΡ, Π½ΠΎ Π½Π΅ Π·Π°Π±ΡΠ²Π°ΠΉΡΠ΅ β ΠΏΡΠ°Π²ΠΈΠ»Π° ΠΌΠΎΠΆΠ½ΠΎ Π½Π°ΡΡΡΠ°ΡΡ:).
ΠΠ»Ρ ΠΌΠ΅Π½Ρ β Qt Coding Style ΠΏΡΠΎΡΡΠΎ ΠΈΠ΄Π΅Π°Π»ΡΠ½ΡΠΉ ΡΡΠΈΠ»Ρ Π΄Π»Ρ Π½Π°ΠΏΠΈΡΠ°Π½ΠΈΡ ΠΊΠΎΠ΄Π°. Π― ΡΡΠΈΡΠ°Ρ Π΅Π³ΠΎ ΡΠΈΡΡΡΠΌ, ΡΠ΄ΠΎΠ±Π½ΡΠΌ, ΠΏΡΠΈΡΡΠ½ΡΠΌ. ΠΠ° Π²ΡΠ΅ Π²ΡΠ΅ΠΌΡ Π΅Π³ΠΎ ΠΈΡΠΏΠΎΠ»ΡΠ·ΠΎΠ²Π°Π½ΠΈΡ Ρ ΠΌΠ΅Π½Ρ Π½Π΅ Π²ΠΎΠ·Π½ΠΈΠΊΠ»ΠΎ Π½ΠΈΠΊΠ°ΠΊΠΈΡ ΠΏΡΠΎΠ±Π»Π΅ΠΌ Ρ ΡΠΈΡΠ°Π±Π΅Π»ΡΠ½ΠΎΡΡΡΡ ΠΊΠΎΠ΄Π°. ΠΡΠ΄Ρ Π»ΠΈ Ρ Π΅Π³ΠΎ ΡΠ΅ΠΊΠΎΠΌΠ΅Π½Π΄ΠΎΠ²Π°ΡΡ? ΠΠΎΠ½Π΅ΡΠ½ΠΎ, Π΄Π°! Π’Π΅ΠΌ Π±ΠΎΠ»Π΅Π΅, Ρ ΡΡΠΈΡΠ°Ρ ΡΡΠΎ ΠΈΠΌΠ΅Π½Π½ΠΎ Π΅Π³ΠΎ ΠΈ Π½Π°Π΄ΠΎ ΠΏΡΠΎΠΏΠ°Π³Π°Π½Π΄ΠΈΡΠΎΠ²Π°ΡΡ Π²ΡΠ΅ΠΌ Π½ΠΎΠ²ΠΈΡΠΊΠ°ΠΌ Π½Π° ΠΏΠ»Π°ΡΡΠΎΡΠΌΠ΅ Qt.
Qt Documentation
Beautifying Source Code
You can use the experimental Beautifier plugin to format your source code by using the following external tools:
The Beautifier plugin parses the source code into component structures, such as assignment statements, if blocks, loops, and so on, and formats them as specified in the Beautifier options. You can use a predefined style or define your own style.
To use the Beautifier plugin:
You might have to build the tools from sources for some platforms.
This setting is applied only when automatically beautifying files on save. To restrict the MIME types when selecting the menu item to format the currently open file, specify this option in the tool-specific tab.
To specify a fallback style to use if the style configuration file is not available, use the Fallback style combo box. Select Default to use the default style. Select None to skip formatting.
Define code formatting in the Add Configuration dialog. It provides syntax highlighting, auto-completion, and context-sensitive help. For these features, you must have the tool installed.
You can create keyboard shortcuts for the functions.
ΠΒ© 2021 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.
Qt Documentation
Contents
When you type text or code, it is indented automatically according to the selected text editor or code style options. Select a block to indent it when you press Tab. Press Shift+Tab to decrease the indentation. You can disable automatic indentation.
You can specify indentation for:
To fix the indentation in the file currently open in the editor, select options in the Edit > Advanced menu or use keyboard shortcuts:
Specifying Indentation Settings
You can also specify indentation 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 automatically fix indentation according to the indentation settings when you save the file, select Tools > Options > Text Editor > Behavior > Clean whitespace > Clean indentation. Select the Skip clean whitespace for file types check box to exclude the specified file types.
To visualize whitespace in the editor, select Tools > Options > Text Editor > Display > Visualize whitespace.
To help you keep line length at a particular number of characters, set the number of characters in the Display right margin at column field. To use a context-specific margin when available, select the Use context-specific margin check box. For example, the margin could be set by the ColumnLimit option of the Clang Format plugin.
Indenting C++ Files
To specify indentation settings for the C++ editor:
You can specify how to:
You can use the live preview to see how the options change the indentation.
To specify different settings for a particular project, select Projects > Code Style Settings.
Automatic Formatting and Indentation
The Clang Format plugin uses the LibFormat library for automatic formatting and indentation.
To enable the plugin, select Help > About Plugins > C++ > ClangFormat. Then select Restart Now to restart Qt Creator and load the plugin.
Note: If you enable the plugin, do not use the Beautifier, because combining the two can provide unexpected results.
To specify settings for automatic formatting and indentation:
Note: This is not recommended, because it defeats the purpose of a Clang format file.
Indenting QML Files
To specify settings for the Qt Quick editor:
You can specify how to interpret the Tab key presses and how to align continuation lines.
To specify different settings for a particular project, select Projects > Code Style Settings.
Indenting Nim Files
To specify settings for the Nim editor (experimental):
You can specify how to interpret the Tab key presses and how to align continuation lines.
To specify different settings for a particular project, select Projects > Code Style.
Indenting Other Text Files
To specify indentation settings for text files that do not contain C++ or QML code (such as Python code files), select Tools > Options > Text Editor > Behavior.
To specify different settings for a particular project, select Projects > Editor.
You can specify how to interpret the Tab and Backspace key presses and how to align continuation lines.
Specifying Tab Settings
You can specify tab settings at the following levels:
Specifying Tabs and Indentation
You can specify tab policy and tab size in the Tabs and Indentation group. In the Tab policy field, select whether to use only spaces or only tabs for indentation, or to use a mixture of them.
By default, the tab length in code editor is 8 spaces and the indent size is 4 spaces. You can specify the tab length and indent size separately for each project and for different types of files.
You can have continuation lines aligned with the previous line. In the Align continuation lines field, select Not at all to disable automatic alignment and indent continuation lines to the logical depth. To always use spaces for alignment, select With Spaces. To follow the Tab policy, select With Regular Indent.
Specifying Typing Options
When you type text or code, it is indented automatically according to the selected text editor or code style options. To specify typing options, select Tools > Options > Text Editor > Behavior > Typing.
To disable automatic indentation, deselect the Enable automatic indentation check box.
You can specify how the indentation is decreased when you press Backspace in the Backspace indentation field. To go back one space at a time, select None. To decrease indentation in leading white space by one level, select Follows Previous Indents. To move back one tab length if the character to the left of the cursor is a space, select Unindents.
You can specify whether the Tab key automatically indents text when you press it. To automatically indent text, select Always in the Tab key performs auto-indent field. To only indent text when the cursor is located within leading white space, select In Leading White Space.
Specifying Settings for Content
You can indent public, protected, and private statements and declarations related to them within classes.
You can also indent statements within functions and blocks and declarations within namespaces.
Specifying Settings for Braces
You can indent class, namespace, enum and function declarations and code blocks.
Specifying Settings for Switch Statements
You can indent case or default statements, or statements or blocks related to them within switch statements.
Specifying Alignment
You can also add spaces to conditional statements, so that they are not aligned with the following line. Usually, this only affects if statements.
Binding Pointers and References
To bind pointers ( * ) and references ( & ) in types and declarations to identifiers, type names, or left or right const or volatile keywords, select the check boxes in the Pointers and References tab.
The * and & characters are automatically bound to identifiers of pointers to functions and pointers to arrays.
Naming Getters
To prefer getter names without the string get, select the Prefer getter names without «get» check box in the Getter and Setter tab.
ΠΒ© 2021 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.
Qt Documentation
Specifying Code Style Settings
Qt Creator uses the MIME type of the file to determine which mode and editor to use for opening the file. Qt Creator opens C++ files in Edit mode in the C++ code editor and QML files in the Qt Quick editor.
You can configure the code style according to your needs. You can specify code style either globally for all projects 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 specify global code style settings sets for C++ files, select Tools > Options > C++.
To specify global code style settings sets for QML files, select Tools > Options > Qt Quick.
To configure the editor behavior for the current project:
Note: Only General settings are available for QML files.
For more information about the settings, see Indenting Text or Code.
ΠΒ© 2021 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.
[ΡΠ΅ΡΠ΅Π½ΠΎ]ΠΠ°ΡΡΡΠΎΠΉΠΊΠ° Π΄ΠΎΠΏΠΎΠ»Π½Π΅Π½ΠΈΡ ΠΊΠΎΠ΄Π° ΠΏΡΠΎΠ±Π΅Π»Π°ΠΌΠΈ Qt Creator 3.3.2
ΠΠΎΠ±ΡΠΎΠ³ΠΎ Π²ΡΠ΅ΠΌΠ΅Π½ΠΈ ΡΡΡΠΎΠΊ!
ΠΠΎΠ΄ΡΠΊΠ°ΠΆΠΈΡΠ΅ ΠΏΠΎΠΆΠ°Π»ΡΠΉΡΡΠ°, ΠΊΠ°ΠΊ Π½Π°ΡΡΡΠΎΠΈΡΡ Qt Creator, ΡΡΠΎΠ±Ρ ΠΎΠ½ Π°Π²ΡΠΎΠΌΠ°ΡΠΈΡΠ΅ΡΠΊΠΈ Π²ΡΡΠ°Π²Π»ΡΠ» ΠΏΡΠΎΠ±Π΅Π»Ρ Π² ΡΠ°ΠΊΠΎΠ³ΠΎ ΡΠΎΠ΄Π° ΠΊΠΎΠ΄. Π§ΡΠΎΠ±Ρ ΠΊΠΎΠ³Π΄Π° Ρ ΠΏΠ΅ΡΠ°ΡΠ°Ρ
Π₯ΠΎΡΠ΅ΡΡΡ Π΄ΠΎΠ±ΠΈΡΡΡΡ ΡΠ°ΠΊΠΎΠ³ΠΎ ΠΏΠΎΠ²Π΅Π΄Π΅Π½ΠΈΡ ΠΎΡ Qt Creator, ΠΊΠ°ΠΊ ΡΡΠΎ ΡΠ΄Π΅Π»Π°Π½ΠΎ Π² Visual Studio(ΠΏΠΎ ΠΊΡΠ°ΠΉΠ½Π΅ΠΉ ΠΌΠ΅ΡΠ΅ Π² 2012, ΡΠΎΠ»ΡΠΊΠΎ Π² Π½Π΅ΠΉ ΡΠ°Π±ΠΎΡΠ°Π»)
ΠΡΠΎ Π½Π΅ Π°Π²ΡΠΎΠ΄ΠΎΠΏΠΎΠ»Π½Π΅Π½ΠΈΠ΅, Π° ΡΠΎΡΠΌΠ°ΡΠΈΡΠΎΠ²Π°Π½ΠΈΠ΅.
ΠΠ°, ΠΊΠΎΠ½Π΅ΡΠ½ΠΎ. Π― Π½Π΅ΠΏΡΠ°Π²ΠΈΠ»ΡΠ½ΠΎ Π²ΡΡΠ°Π·ΠΈΠ»ΡΡ.
Π’ΠΎΠ³Π΄Π° ΠΈΡΠΏΡΠ°Π²Π»ΡΡΡ Ρ. ΠΠ°ΠΊ ΠΌΠ½Π΅ Π½Π°ΡΡΡΠΎΠΈΡΡ ΡΠ°ΠΊΠΎΠ΅ Π²ΠΎΡ Π°Π²ΡΠΎΠΌΠ°ΡΠΈΡΠ΅ΡΠΊΠΎΠ΅ ΡΠΎΡΠΌΠ°ΡΠΈΡΠΎΠ²Π°Π½ΠΈΠ΅ ΠΊΠΎΠ΄Π°?
ΠΠ»Ρ ΡΡΠΎΠ³ΠΎ Π΅ΡΡΡ ΠΏΠ»Π°Π³ΠΈΠ½ Beautifier. ΠΡΠΈΠ΄Π΅ΡΡΡ ΡΠΎΠ»ΡΠΊΠΎ Π²ΡΡΡΠ½ΡΡ (ΠΏΠΎ Ρ ΠΎΡΠΊΠ΅Ρ) Π΅Π³ΠΎ Π·Π°ΠΏΡΡΠΊΠ°ΡΡ.
Ρ ΠΏΡΠΎΡΡ ΠΏΡΠΎΡΠ΅Π½ΠΈΡ, Π½ΠΎ Π½Π΅Ρ Π»ΠΈ Ρ ΠΊΠΎΠ³ΠΎ-Π½ΠΈΠ±ΡΠ΄Ρ Π³ΠΎΡΠΎΠ²ΠΎΠ³ΠΎ ΠΊΠΎΠ½ΡΠΈΠ³Π° ΠΏΠΎΠ΄ ΡΡΠΈΠ»Ρ Π°Π»Ρ Visual Studio? (ΠΌΠ½Π΅ ΠΊΠΎΠ½ΡΠΈΠ³ Π½ΡΠΆΠ΅Π½ Π΄Π»Ρ unsucrustify)
ΠΈ ΠΊΠ°ΠΊ Π½Π°ΡΡΡΠΎΠΈΡΡ ΡΠΎΡΠΌΠ°ΡΠΈΡΠΎΠ²Π°Π½ΠΈΠ΅ ΠΊΠΎΠ΄Π° ΠΏΠΎ Π½Π°ΠΆΠ°ΡΠΈΡ Π³ΠΎΡΡΡΠ΅ΠΉ ΠΊΠ»Π°Π²ΠΈΡΠΈ Π² QT Creator?
ΠΡΡ, ΡΠ΅ΡΠ΅Π½ΠΎ. Π‘ΠΏΠ°ΡΠΈΠ±ΠΎ Π²ΡΠ΅ΠΌ
ΠΡΠ»ΠΈ Π±Ρ ΡΡ ΡΡΡ ΠΎΠΏΠΈΡΠ°Π» ΠΊΠ°ΠΊ ΡΠ΅ΡΠ°Π», ΡΠΎ ΠΌΠΎΠΆΠ΅Ρ ΡΡΠΎ ΠΊΠΎΠΌΡ-ΡΠΎ Π² Π±ΡΠ΄ΡΡΠ΅ΠΌ ΠΏΡΠΈΠ³ΠΎΠ΄ΠΈΠ»ΠΎΡΡ Π±Ρ.
Π°, Π΄Π°, ΠΊΠΎΠ½Π΅ΡΠ½ΠΎ. ΠΡΠΎΡΡ ΠΏΡΠΎΡΠ΅Π½ΠΈΡ π
Π Π΅ΡΠΈΠ» ΠΏΡΠΈ ΠΏΠΎΠΌΠΎΡΠΈ ΡΡΡΠ°Π½ΠΎΠ²ΠΊΠΈ ΠΏΠ»Π°Π³ΠΈΠ½Π° Beautifier Π² QT(ΡΠ°ΠΌ ΡΡΠ°Π²ΠΈΡΡΡ Π΅ΡΡ ΠΏΠΎ Π²ΡΠ±ΠΎΡΡ 3 ΠΌΠΎΠ΄ΡΠ»Ρ, ΠΏΠΎ ΡΡΡΠΈ Π΄Π΅Π»Π°ΡΡΠΈΠ΅ ΠΎΠ΄Π½ΠΎ ΠΈ ΡΠΎ ΠΆΠ΅ : astyle, clang ΡΡΠΎ-ΡΠΎ ΡΠ°ΠΌ, unsucrucstifier). Π― ΠΏΠΎΠ»ΡΠ·ΡΡΡΡ ΠΏΠΎΡΠ»Π΅Π΄Π½ΠΈΠΌ, Π½Π°ΡΡΡΠΎΠΈΠ² Π΅Π³ΠΎ ΠΊΠΎΠ½ΡΠΈΠ³. Π Π·Π°Π±ΠΈΠ½Π΄ΠΈΠ» Π΅Π³ΠΎ Π²ΡΠ·ΠΎΠ² Π² Π½Π°ΡΡΡΠΎΠΉΠΊΠ°Ρ Π½Π° Π³ΠΎΡΡΡΡΡ ΠΊΠ»Π°Π²ΠΈΡΡ. Π Π²ΡΠ΅ΠΌΡ ΠΎΡ Π²ΡΠ΅ΠΌΠ΅Π½ΠΈ ΠΏΡΠΎΠΆΠΈΠΌΠ°Ρ. Π ΠΊΠΎΠ΄ Π±Π»Π΅ΡΡΠΈΡ ΠΈ Π³Π»Π°Π· ΡΠ°Π΄ΡΠ΅ΡΡΡ, ΠΈ ΠΊΠΎΠΌΠΌΠΈΡΠΈΡΡ Π½Π΅ ΡΡΡΠ΄Π½ΠΎ