Search code examples
qtqmessagebox

How to display plain text using QMessageBox?


I need to display an HTML text:

QString text="<b>Hello</b>";
QMessageBox::information(this,"info", text);

The text is displayed as bold "Hello". How to display it as it is, i.e.,

<b>Hello</b>

Thanks!


Solution

  • You have to use the method toHtmlEscaped() of QString:

    QString text="<b>Hello</b>";
    QMessageBox::information(this, "info", text.toHtmlEscaped());