This simple guide might be maintained for my needs.
Todo: convert default vscode format setting into clang formatter style
Todo2: figure out right way to use project specific setting.
- Install Microsoft Visual Studio 2019 Installer
- Launch installer
- Choose
individual components
- Search for
MSVC v142 - VS 2019 C++ x64/x86 build tools (Latest)
&Windows 10 SDK(10.0.19041.0)
&C++ ATL for latest v142 build tools (x86 & x64)
&C++ ATL for latest v142 build tools (x86 & x64) with Spectre Mitigations
(optional), check them all, install them all
- Install Aqtinstaller executable binary (As this executable binary is not signed, Malware Detecting Apps highly diagnosis this as malware.)
- Make Qt directory in someware
- Locate downloaded file there and rename it as
aqt
if not. - open cmd in that directory
- execute command
aqt list-qt windows desktop
- you can see the list of Qt versions. You can choose highest. I'll choose 6.3.0 - execute command
aqt list-qt windows desktop --arch 6.3.0
- you can see the list of compatible compilers for the providen Qt version. I'll choose win64_msvc2019_64 - execute command
aqt_x64 install-qt windows desktop 6.3.0 win64_msvc2019_64
to download Qt
- execute command
aqt_x64 list-tool windows desktop
- you can see the list of Qt tools. I need qtdesignstudio, so I'll choose it. - execute command
aqt_x64.exe list-tool windows desktop tools_qtdesignstudio_generation2 -l
to check if there is any variant of this tool. - execute command
aqt_x64.exe install-tool windows desktop tools_qtdesignstudio_generation2
to download Qt tool, qtdesignstudio
- execute command
aqt_x64 list-tool windows desktop
- you can see the list of Qt tools. I need qtcreator, so I'll choose it. - execute command
aqt_x64.exe install-tool windows desktop tools_qtcreator
to download Qt tool, qtcreator
- At the top menu bar, click
Tools > Options
- Click
Kits
menu and clickAdd
button at the right edge. - Click the newely created kit under Manual. And handle some options, click OK
Device type: Desktop
Device: Local PC(default for Desktop)
Build device: Local PC(default for Desktop)
Sysroot: C:
Compiler:
C: Microsoft Visual C++ Compiler blabla (amd64)
C++: Microsoft Visual C++ Compiler blabla (amd64)
Debugger: Auto-detected blabla
Qt version: click "Manage" and click "Add" button. go to the bin path inside the directory you installed Qt. In my case, the path was "C:\Qt\6.3.0\msvc2019_64\bin\qmake6.exe". Then go back to Kits tab and choose what you added.
...
CMake Tool: Auto detected Cmake blabla...
...
- At the top menu bar, click
Tools > Options
- Click
C++
menu and go toFile Naming
tab. add your Windows SDK ucrt path toSearch paths
. In my case, the path wasC:\Program Files (x86)\Windows Kits\10\Include\10.0.19041.0\ucrt
. So, fullSearch paths
would be likeinclude,Include,..\include,..\Include,C:\Program Files (x86)\Windows Kits\10\Include\10.0.19041.0\ucrt
- Click OK
- Go to
Help > About Plugins...
- In
C++
, checkBeautifier (experimental)
- Click
close
and restart Qtcreator - Go to
Tools > Options
- Click
Beautifier
menu. InGeneral
tab, setTool: ClangFormat
- In
Clang Format
tab, ConfigureClang Format command
. If you already installed C++ extension for Visual Studio Code, you can find a executableclang-format.exe
in pathC:\Users\USER-\.vscode\extensions\ms-vscode.cpptools-1.8.4\LLVM\bin
. Or you need to download the LLVM - In Options, You can choose from two options. One is via
.clang-format
file and other is via commandline argument.
7-1. In case you want to use.clang-format
file, checkUse predefined style: File
andFallback style: None
. Then open file explorer and go to installed Qtcreator path (..\Tools\QtCreator
). Put any .clang-format file there. (Currently not working properly for me and Idk why)
7-2. In case you want to use commandline argument, checkUse customized style
andadd
One. the Value format should be like this (99% Similar to the Visual Studio Code's one)
{BasedOnStyle: llvm,Standard: Latest,AccessModifierOffset: -2,AlignAfterOpenBracket: Align,ColumnLimit: 0,IndentWidth: 2,NamespaceIndentation: All,BreakBeforeBraces: Allman,UseTab: Never,TabWidth: 2,PointerAlignment: Right}
- Make shortcut for formatting code. Go to
Environment
menu. InKeyboard
tab, putclangformat.formatfile
inFilter
field. Click FormatFile and input any shortcut you like intoKey sequence
. In my case,Ctrl+Alt+F
. - Click OK and everything is done. Except when you press tab, indent is fixed to 4 spaces. To change this, go to
Tools > Options
andC++
menu. InCode Style
tab, clickEdit...
. InGeneral
tab, setTab size
andIndent size
as you wish. ClickCopy Built-in Code Style
button in top right, then ClickOk -> Ok
. Now try pressTap
key anywhere. Indent works great.
More format style here