Qt for Windows - Windows App SDK

配置

要使用 Windows App SDK in Qt apps, configure the SDK path.

使用 Qt Creator

To configure the Windows App SDK in Qt Creator, go to 首选项 > SDKs .

\QC SDKs Preferences.

更多信息,见 Qt Creator Documentation .

From the command line

  1. Go to an empty directory.

    范例:

    mkdir C:\Dev\wasdk
    cd C:\Dev\wasdk
    							
  2. 下载 NuGet into that directory.

    For example, to download with PowerShell from the command line:

    powershell.exe -Command "& {Invoke-WebRequest https://dist.nuget.org/win-x86-commandline/latest/nuget.exe -OutFile nuget.exe}"
    							
  3. Download the Windows App SDK with NuGet.
    nuget.exe install Microsoft.WindowsAppSDK -OutputDirectory ./
    							
  4. 设置 WIN_APP_SDK_ROOT environment variable to the Windows APP SDK directory, usually called Microsoft.WindowsAppSDK.{Version} .

    For example, using the command-line:

    cd Microsoft.WindowsAppSDK.*
    set WIN_APP_SDK_ROOT=%cd%
    setX WIN_APP_SDK_ROOT %cd%
    							

Using the Windows App SDK in Qt apps

调用 qt_add_win_app_sdk (ProjectName) CMake function in the project's CMake file. Replace ProjectName with your project name.

Use a condition to ensure the build is only for MSVC builds:

if (MSVC)
    qt_add_win_app_sdk(ProjectName)
endif()