Important: Please read the Qt Code of Conduct -

How QTreeWidgetItem::QTooltip setFixedWidth ?

  • QTreeWidgetItem.setTooltip(s) is too wide, need fixed width.

  • As far as I know, you can't.
    But it accepts rich text, so you can add html <br/> tag to your text to make it start a new line.

  • @sonichy
    As @Bonnie has written, <br/>. I reply to illustrate this because I actually found them too narrow! I wanted to make it so they only wrap on <br/>, and so have:

    QString UIUtils::tooltipTextNoWrap(const QString &text)
        //make tooltip text not wrap, so that it is wide and only breaks on explicit embedded "<br/>"
        return QString("<style>p { margin: 0 0 0 0 }</style><p style=\"white-space:pre\">%1</p>").arg(text);;

    If you wish to control exactly where your tooltips wrap this can be used.

Log in to reply