View Full Version : QToolTip doesnt wrap text

16th August 2011, 20:12
I have a QTreeView and some of the items text gets truncated.
I want to display a tooltip for those items. The thing is that when i display the tooltip, its also truncated.

The word wrap only works with spaces. In my case i have a long email, and it cuts me the last 3 or 4 chars. i've tried adding the <p> tags so its rich text, and also just setting it with plain text, but still not working.

item->setToolTip("<p>" + tooltip+ "</p>"); //both have the same result

The hack that i found is that, if i add as many " " (blanks) as the size of the text, then it gets displayed fine.

QString filler;
filler.fill(' ', tooltip.size());//we need this filler ir order for QT to not cut the long text in the tooltip.
item->setToolTip(tooltip + filler);

If instead of using a variable i set a large text manually, it works great.

item->setToolTip("tttttttttttttttttttttttttttttttttttttttttttttttttt ttttttttttttttttttttttttttttttttttttttttX");

any ideas?