qtooltip在单行qt中显示句子

qtooltip show sentence in single line qt

在单行中显示没有任何富文本的工具提示效果很好。但是我的工具提示中有富文本。

QString tooltip="<span class=nobr>This is a much longer line than the first</span>";

分 3 行显示。我怎样才能将它限制为 1 行。我尝试过的东西

QString tooltip="<nobr>This is a much longer line than the first</nobr>";
QString tooltip="<span class=nobr>This is a much longer line than the first</span>";
QString tooltip="<span 'white-space:nowrap'>This is a much longer line than the first</span>";

如何在单行中显示带有富文本的工具提示 提前致谢

文档状态:

Rich text displayed in a tool tip is implicitly word-wrapped unless specified differently with <p style='white-space:pre'>.

所以这样的事情会起作用:

QString tooltip = "<p style='white-space:pre'>This is a much longer line than the first</p>";