Qt for Windows - Windows 应用程序 SDK
配置
要在 Qt 应用程序中使用Windows App SDK,请配置 SDK 路径。
使用Qt Creator
要在Qt Creator 中配置 Windows App SDK,请访问Preferences >SDKs 。
有关详细信息,请参阅Qt Creator 文档。
从命令行
- 转到一个空目录。
例如
mkdir C:\Dev\wasdk cd C:\Dev\wasdk
- 将NuGet下载到该目录。
例如,使用 PowerShell 从命令行下载:
powershell.exe -Command "& {Invoke-WebRequest https://dist.nuget.org/win-x86-commandline/latest/nuget.exe -OutFile nuget.exe}"
- 使用 NuGet 下载 Windows App SDK。
nuget.exe install Microsoft.WindowsAppSDK -OutputDirectory ./
- 将
WIN_APP_SDK_ROOT
环境变量设置为 Windows APP SDK 目录,通常称为Microsoft.WindowsAppSDK.{Version}
。例如,使用命令行
cd Microsoft.WindowsAppSDK.* set WIN_APP_SDK_ROOT=%cd% setX WIN_APP_SDK_ROOT %cd%
在 Qt 应用程序中使用 Windows App SDK
调用项目 CMake 文件中的qt_add_win_app_sdk(ProjectName) CMake 函数。将ProjectName替换为项目名称。
使用条件确保只针对 MSVC 构建:
if (MSVC) qt_add_win_app_sdk(ProjectName) endif()
© 2025 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.