qtooltip在单行qt中显示句子

时间:2015-01-21 11:38:04

标签: qt qt5

在一行中显示没有任何富文本的工具提示正常工作。但我的工具提示中有丰富的文字。

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>";

如何在单行中显示包含富文本的工具提示 提前谢谢

1 个答案:

答案 0 :(得分:4)

文档声明:

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>";