Windows应用程序SDK支持

Windows App SDK Support

Windows应用程序SDK支持

January 22, 2025 by Morteza Jamshidi | Comments

​2025年1月22日由Morteza Jamshidi发表|评论

We're happy to announce the first release of our Windows App SDK official support in Qt!

我们很高兴地宣布在Qt中首次发布我们的Windows App SDK官方支持!

Before this version of Qt, developers had to integrate the Windows App SDK manually. However, with the release of Qt Creator 16, this process will become much easier, allowing developers to use the Windows App SDK in their Qt apps and libraries seamlessly.

在此版本的Qt之前,开发人员必须手动集成Windows App SDK。然而,随着Qt Creator 16的发布,这一过程将变得更加容易,允许开发人员在他们的Qt应用程序和库中无缝使用Windows App SDK。

What is Windows App SDK?

什么是Windows应用程序SDK?

The Windows App SDK, formerly known as Project Reunion, is Microsoft’s initiative to provide a cohesive development platform for building modern, native Windows applications. It unifies various tools, libraries, and frameworks to simplify app development while ensuring compatibility across different versions of Windows. This approach allows developers to leverage the best of both Win32 and Universal Windows Platform (UWP) environments in a single project.

​Windows App SDK,以前称为Project Reunion,是微软为构建现代原生Windows应用程序提供一个有凝聚力的开发平台的举措。它统一了各种工具、库和框架,以简化应用程序开发,同时确保跨不同版本的Windows的兼容性。这种方法允许开发人员在单个项目中利用Win32和通用Windows平台(UWP)环境的最佳特性。

Key Features and Components:

主要功能和组件:

  • WinUI (Windows UI Library):
    WinUI(Windows用户界面库):

    Provides modern user interface controls and styles for building visually appealing and responsive applications.

    提供现代用户界面控件和样式,用于构建视觉上吸引人且响应迅速的应用程序。

    Supports high-DPI displays, touch input, and fluent design principles for an enhanced user experience.

    支持高DPI显示、触摸输入和流畅的设计原则,以增强用户体验。

  • WebView2:

    Integrates web content into native applications using the Microsoft Edge Chromium engine.

    使用Microsoft Edge Chromium引擎将web内容集成到本机应用程序中。

    Ensures seamless embedding of HTML, CSS, and JavaScript alongside native code.

    确保HTML、CSS和JavaScript与本机代码无缝嵌入。

  • Advanced App Lifecycle Management:

    高级应用生命周期管理:

    Offers robust support for app activation, background tasks, and state restoration.

    为应用程序激活、后台任务和状态恢复提供强大的支持。

    Facilitates optimal performance and efficient resource utilization.

    促进最佳性能和高效资源利用。

  • Cross-Version Compatibility:

    跨版本兼容性:

    Enables apps to run on a wide range of Windows versions without requiring multiple codebases.

    使应用程序能够在各种Windows版本上运行,而不需要多个代码库。

    Reduces development complexity and maintenance efforts.

    降低开发复杂性和维护工作量。

  • Consistent API Surface:

    一致的API表面:

    Introduces a unified set of APIs for modern app development, replacing fragmented approaches of the past.

    为现代应用程序开发引入了一组统一的API,取代了过去零散的方法。

    Simplifies access to advanced system features like notifications, windowing, and file handling.

    简化了对通知、窗口和文件处理等高级系统功能的访问。

Setup

设置

There are two ways to integrate the Windows App SDK with Qt:

有两种方法可以将Windows App SDK与Qt集成:

Using Qt Creator:
使用Qt Creator:

Details can be found in the Qt Creator Documentation.

​详细信息可以在Qt Creator文档中找到。

Using Command line:
使用命令行:

1.Go to an empty directory.

1.转到空目录。
Example:

示例:

mkdir C:\Dev\wasdk
cd C:\Dev\wasdk

2.Download NuGet into that directory.

​2.将NuGet下载到该目录中。

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

例如,要使用PowerShell从命令行下载:

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.

3.使用NuGet下载Windows应用程序SDK。

nuget.exe install Microsoft.WindowsAppSDK -OutputDirectory ./

4.Set the WIN_APP_SDK_ROOT environment variable to the Windows APP SDK directory, usually called Microsoft.WindowsAppSDK.{Version}.

4.将WIN_APP_SDK_ROOT环境变量设置到Windows APP SDK目录,通常称为Microsoft.WindowsAppSDK.{Version}。

For example, using the command-line:

例如,使用命令行:

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

Note: The set command assigns the variable locally, while setX assigns it globally.

注意:set命令在本地分配变量,而setX在全局分配变量。

Usage

用法

Call qt_add_win_app_sdk(ProjectName) CMake function in the project's CMake file.

在项目的CMake文件中调用qt_add_win_app_sdk(项目名称)CMake函数。

Replace ProjectName with your project name.

将ProjectName替换为项目名称。

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

使用条件确保构建仅适用于MSVC构建:

if (MSVC)
    qt_add_win_app_sdk(ProjectName)
endif()

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值