Windows 中 QSystemTrayIcon 工具提示的最大长度是多少?

Which is the QSystemTrayIcon tooltip max length in Windows?

我在 QSystemTrayIcon::toolTip 的 Qt 5.8 文档中读到:

This property holds the tooltip for the system tray entry.

On some systems, the tooltip's length is limited. The tooltip will be truncated if necessary.

那我想知道Windows10的极限是多少

我在 About Tooltip Controls 中看到

Note The maximum length for standard tooltip text is 80 characters. For more information, see the NMTTDISPINFO structure. Multiline tooltip text can be longer.

然后,我有一个用 Qt 创建的多行工具提示,我在 Windows10 中看到最大长度为 123 个字符(如果算上换行符,可能会更长一些,比如 ~130)。

我的问题是:这是 Windows 10 中多行工具提示的最大长度(~130 个字符)吗?我能否根据系统从 Qt 获取此信息(如果应用程序在不同的 OS 上 运行),以便我可以正确更改工具提示文本?

谢谢大家

在 Windows 2000 及更高版本中,工具提示的最大长度为 128 个字符。这在 MSDN 中记录为 NOTIFYICONDATA structure:

szTip

Type: TCHAR[64]

A null-terminated string that specifies the text for a standard tooltip. It can have a maximum of 64 characters, including the terminating null character.

For Windows 2000 and later, szTip can have a maximum of 128 characters, including the terminating null character.

关于可移植性,这是一个非常 system-specific 的价值,所以我认为您无法使用纯 Qt 获得它。例如,Linux 中不同的 windows 经理可能有不同的长度限制。


另一方面,为了完整起见,system-tray 气球中的文本长度更大(Windows 2000 年及以后,取自同一来源):

szInfo

Type: TCHAR[256]

Windows 2000 and later. A null-terminated string that specifies the text to display in a balloon notification. It can have a maximum of 256 characters, including the terminating null character, but should be restricted to 200 characters in English to accommodate localization. To remove the balloon notification from the UI, either delete the icon (with NIM_DELETE) or set the NIF_INFO flag in uFlags and set szInfo to an empty string.

同样,标题的长度是:

szInfoTitle

Type: TCHAR[64]

Windows 2000 and later. A null-terminated string that specifies a title for a balloon notification. This title appears in a larger font immediately above the text. It can have a maximum of 64 characters, including the terminating null character, but should be restricted to 48 characters in English to accommodate localization.

dwInfoFlags

Type: DWORD

Windows 2000 and later. Flags that can be set to modify the behavior and appearance of a balloon notification. The icon is placed to the left of the title. If the szInfoTitle member is zero-length, the icon is not shown.