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
aqtif 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_64to 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 -lto check if there is any variant of this tool. - execute command
aqt_x64.exe install-tool windows desktop tools_qtdesignstudio_generation2to 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_qtcreatorto download Qt tool, qtcreator
- At the top menu bar, click
Tools > Options - Click
Kitsmenu and clickAddbutton 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 Namingtab. 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 pathswould 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
closeand restart Qtcreator - Go to
Tools > Options - Click
Beautifiermenu. InGeneraltab, setTool: ClangFormat - In
Clang Formattab, ConfigureClang Format command. If you already installed C++ extension for Visual Studio Code, you can find a executableclang-format.exein 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-formatfile and other is via commandline argument.
7-1. In case you want to use.clang-formatfile, checkUse predefined style: FileandFallback 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 styleandaddOne. 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
Environmentmenu. InKeyboardtab, putclangformat.formatfileinFilterfield. 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 > OptionsandC++menu. InCode Styletab, clickEdit.... InGeneraltab, setTab sizeandIndent sizeas you wish. ClickCopy Built-in Code Stylebutton in top right, then ClickOk -> Ok. Now try pressTapkey anywhere. Indent works great.
More format style here