need to show 2 line text in tooltip with bold and multicolor characters, but seems tooltip has max width and text was cut. I tried to calculate width of text and set width manually, but it doesn't make any effects, seems style = "width: some px" doesn't work for tooltip. Here's the code:
Edited
QString tooltip = "<div style= \"white-space: nowrap; width: 1500px;\">Some text for tooltip, which is too long</div>";
How can I change tooltip width?
Using the properties portion of QtCreator/Designer, I used:
<html>
<table width="25">
<tr>
<td width="25">alwkefjwekf</td>
</tr>
<tr>
<td width="25">a ea ea ea ea ea ea ea ea ea ea ea ea ea ea ea ea e</td>
</tr>
</table>
</html>
This should help clue you in on how to better limit the size of the table. I have no doubt that there is probably a more terse way to express this.
A concrete example generated by QtCreator:
pushButton->setToolTip(QApplication::translate("MainWindow", " <html>\n"
" <table width=\"25\"><tr><td width=\"25\">alwkefjwekf</td></tr>\n"
" <tr><td width=\"25\">a ea ea ea ea ea ea ea ea ea ea ea ea ea ea ea ea e</td></tr>\n"
" </table>\n"
" </html>", 0));
This is a little bit cleaner ...
Also, don't set "white-space: nowrap;", doing that with a small width will cut off text
And, when possible, don't hard code class names, since there is no __CLASS__ I used __FUNCTION__
If you really want the class name for Qt Linguist ( the translate function ) make sure the RTTI compiler option is on and
use typeid(*this).name()
setToolTip( QApplication::translate(__FUNCTION__, " <html>\n"
" <div style=\"width: 300px;\">ea ea ea ea ea ea ea ea ea ea ea ea ea ea ea ea ea ea ea ea ea</div>"
" </html>", 0
));
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With