本页内容

桌面集成

Qt 应用程序在用户的桌面环境中运行良好,但某些集成需要采用额外的技术,有时还需采用特定于平台的技术。

有用的类

Qt 中的各种类旨在帮助开发人员将应用程序集成到用户的桌面环境中。这些类使开发人员能够利用原生服务,同时仍可使用跨平台 API。

QDesktopServices

访问常用桌面服务的方法

QSystemTrayIcon

系统托盘中的应用程序图标

打开外部资源

尽管 Qt 提供了处理和显示资源的工具(例如common image formats 和HTML ),但有时仍需要通过外部应用程序来打开文件和外部资源。

QDesktopServices openUrl() 提供了一个接口,用于访问用户桌面环境提供的服务。特别是, () 函数用于通过相应的应用程序打开资源,该应用程序可能已由用户进行了特定配置。

系统托盘图标

许多现代桌面环境都配备了带有系统托盘的停靠栏或面板,应用程序可以在其中安装图标。应用程序通常使用系统托盘图标来显示状态信息,方法是更新图标本身,或者通过“气泡提示”显示信息。此外,许多应用程序还提供可通过其系统托盘图标访问的弹出菜单。

QSystemTrayIcon 类通过直观的Qt风格API提供了上述所有功能,该API可在所有桌面平台上使用。

© 2026 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.