QToolTip with different fonts
-
Hi,
So i was wondering if it is possible to have the text of a QToolTip have multiple fonts. E.g the first line is bold and the second line is italic and so on.
My assumption is that i have to call QToolTip::showText multiple times and set the font between the calls. However for this i have to change the position of the tooltip after each call and for that i would have to know the height of the tooltip box which i dont think is accessible. So how would i solve this? -
Yes i already tried that but i am quite confused as to how this can be used. When using a QTextEdit (this is what the rich text link leads to) i still can only return a QString which is necessary due to the ToolTip function and that QString is n ot using different fonts. Maybe i am using the QTextEdit wrong too, im not sure.
QFont f("Arial", 15, QFont::Bold); QFont g("Arial", 10, QFont::Bold); QTextEdit t; t.setFont(f); t.append("foo\n"); t.setFont(g); t.append("bar"); QToolTip::showText(somePos, t.toPlainText());
-
As its name suggests toPlainText returns that: plain text, no formatting. You should get better result with toHtml.
-
You're welcome !
Since you have it working now, please mark the thread as solved using the "Topic Tools" button or the three dotted menu beside the answer you deem corrected so that other forum users may know a solution has been found :-)