Line breaks in tooltip text
-
Stating the help: http://doc.qt.io/qt-5.9/qtooltip.html
"Rich text displayed in a tool tip is implicitly word-wrapped unless specified differently with <p style='white-space:pre'>."
-
Stating the help: http://doc.qt.io/qt-5.9/qtooltip.html
"Rich text displayed in a tool tip is implicitly word-wrapped unless specified differently with <p style='white-space:pre'>."
-
@mrjj said in Line breaks in tooltip text:
@aha_1980
Cheater ;) reading the docs.. \o/He! Sometimes they are wrong and that makes it even harder :)
-
@mrjj said in Line breaks in tooltip text:
@aha_1980
Cheater ;) reading the docs.. \o/He! Sometimes they are wrong and that makes it even harder :)
-
Hi
Test indicates that yes
-
I'm still trying to do this programmatically, but so far without success. Here's my code:
QString richText = "This area contains messages received from the target device. "\ "Currently target debug information is not displayed."; QLabel l_toolTip; l_toolTip.setText(richText); l_toolTip.setTextFormat(Qt::RichText); ui->plainTextEdit->setToolTip(l_toolTip.text());
What am I doing wrong here?
-
I'm still trying to do this programmatically, but so far without success. Here's my code:
QString richText = "This area contains messages received from the target device. "\ "Currently target debug information is not displayed."; QLabel l_toolTip; l_toolTip.setText(richText); l_toolTip.setTextFormat(Qt::RichText); ui->plainTextEdit->setToolTip(l_toolTip.text());
What am I doing wrong here?
-
@mzimmers
That the text is not rich text.
still just plain text.To cheat you can use Designer and then grab the code from
setupUI()hmm. Odd using your text, it still dont word break :)@mrjj it is rich text according to the debugger:
QString richText = "This area contains messages received from the target device. "\ "Currently target debug information is not displayed."; QLabel l_toolTip; l_toolTip.setText(richText); enum Qt::TextFormat i = l_toolTip.textFormat(); qDebug() << i; l_toolTip.setTextFormat(Qt::RichText); i = l_toolTip.textFormat(); qDebug() << i; ui->plainTextEdit->setToolTip(l_toolTip.text());
I get this:
Qt::TextFormat(AutoText) Qt::TextFormat(RichText)
-
hi
Rich text looks like this
<html><head/><body><p>this area contains messages received from the target device. Currently target debug information is not displayed</p></body></html>
I dont think you can just lie to it about the format.
Code from Designer
pushButton->setToolTip(QApplication::translate("MainWindow", "<html><head/><body><p>this area contains messages received from the target device. Currently target debug information is not displayed</p></body></html>", Q_NULLPTR));
-
hi
Rich text looks like this
<html><head/><body><p>this area contains messages received from the target device. Currently target debug information is not displayed</p></body></html>
I dont think you can just lie to it about the format.
Code from Designer
pushButton->setToolTip(QApplication::translate("MainWindow", "<html><head/><body><p>this area contains messages received from the target device. Currently target debug information is not displayed</p></body></html>", Q_NULLPTR));
@mrjj yeah, you're right...I just discovered that. Somewhat misleading documentation, IMO, but maybe it's just me.
Anyway, this works:
char myToolTip[] = "<html><head/><body><p>This area contains messages " \ "received from the target device. " \ "Currently target debug information is not displayed." \ "</p></body></html>"; ui->plainTextEdit->setToolTip(myToolTip);
Thanks to all for the assistance.