本页

桌面集成

Qt 应用程序在用户的桌面环境中表现良好,但某些集成需要额外的、有时是特定平台的技术。

有用的类

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

QDesktopServices

访问常用桌面服务的方法

QSystemTrayIcon

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

打开外部资源

尽管 Qt XML 提供了处理和显示资源的设施,如common image formatsHTML ,但有时仍有必要使用外部应用程序打开文件和外部资源。

QDesktopServices Qt 提供了一个用户桌面环境所提供服务的接口。特别是,openUrl() 函数用于使用适当的应用程序打开资源,用户可能已对该应用程序进行了专门配置。

系统托盘图标

许多现代桌面环境都有带系统托盘的底座或面板,应用程序可以在其中安装图标。应用程序通常使用系统托盘图标来显示状态信息,要么更新图标本身,要么在 "气球消息 "中显示信息。此外,许多应用程序还提供可通过系统托盘图标访问的弹出式菜单。

QSystemTrayIcon 类通过直观的 Qt XML 风格应用程序接口提供了上述所有功能,可用于所有桌面平台。

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