Skip to content

Instantly share code, notes, and snippets.

@dewcked
Last active February 14, 2022 14:13
Show Gist options
  • Save dewcked/fb0d4661c7298e9c6c382c87506e957e to your computer and use it in GitHub Desktop.
Save dewcked/fb0d4661c7298e9c6c382c87506e957e to your computer and use it in GitHub Desktop.
Windows 10 (amd) Desktop Aqtinstall Qt installation and setting guide

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.

Installation

Install prerequirements.

Install MSVC 2019

  1. Install Microsoft Visual Studio 2019 Installer
  2. Launch installer
  3. Choose individual components
  4. 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 CMake

  1. Install from here

Install Qt

Install basic Qt

  1. Install Aqtinstaller executable binary (As this executable binary is not signed, Malware Detecting Apps highly diagnosis this as malware.)
  2. Make Qt directory in someware
  3. Locate downloaded file there and rename it as aqt if not.
  4. open cmd in that directory
  5. 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
  6. 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
  7. execute command aqt_x64 install-qt windows desktop 6.3.0 win64_msvc2019_64 to download Qt

Install Qt design studio

  1. execute command aqt_x64 list-tool windows desktop - you can see the list of Qt tools. I need qtdesignstudio, so I'll choose it.
  2. execute command aqt_x64.exe list-tool windows desktop tools_qtdesignstudio_generation2 -l to check if there is any variant of this tool.
  3. execute command aqt_x64.exe install-tool windows desktop tools_qtdesignstudio_generation2 to download Qt tool, qtdesignstudio

Install Qt creator

  1. execute command aqt_x64 list-tool windows desktop - you can see the list of Qt tools. I need qtcreator, so I'll choose it.
  2. execute command aqt_x64.exe install-tool windows desktop tools_qtcreator to download Qt tool, qtcreator

Setting

Set Qt design studio (same as Qt creator)

Kits Setting

  1. At the top menu bar, click Tools > Options
  2. Click Kits menu and click Add button at the right edge.
  3. 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...
...

include Windows SDK path

  1. At the top menu bar, click Tools > Options
  2. Click C++ menu and go to File Naming tab. add your Windows SDK ucrt path to Search paths. In my case, the path was C:\Program Files (x86)\Windows Kits\10\Include\10.0.19041.0\ucrt. So, full Search paths would be like include,Include,..\include,..\Include,C:\Program Files (x86)\Windows Kits\10\Include\10.0.19041.0\ucrt
  3. Click OK

Install beautifier plugin

  1. Go to Help > About Plugins...
  2. In C++, check Beautifier (experimental)
  3. Click close and restart Qtcreator
  4. Go to Tools > Options
  5. Click Beautifier menu. In General tab, set Tool: ClangFormat
  6. In Clang Format tab, Configure Clang Format command. If you already installed C++ extension for Visual Studio Code, you can find a executable clang-format.exe in path C:\Users\USER-\.vscode\extensions\ms-vscode.cpptools-1.8.4\LLVM\bin. Or you need to download the LLVM
  7. 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, check Use predefined style: File and Fallback 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, check Use customized style and add 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}
  1. Make shortcut for formatting code. Go to Environment menu. In Keyboard tab, put clangformat.formatfile in Filter field. Click FormatFile and input any shortcut you like into Key sequence. In my case, Ctrl+Alt+F.
  2. Click OK and everything is done. Except when you press tab, indent is fixed to 4 spaces. To change this, go to Tools > Options and C++ menu. In Code Style tab, click Edit.... In General tab, set Tab size and Indent size as you wish. Click Copy Built-in Code Style button in top right, then Click Ok -> Ok. Now try press Tap key anywhere. Indent works great.
@dewcked
Copy link
Author

dewcked commented Feb 14, 2022

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment