How to escape user-provided text as RTF in Qt4 before using it in eg. QMessageBox?
-
13-10-2019 - |
Question
I recently discovered that QMessageBox parses provided text as HTML subset. I want to use it along with user-provided text (name for an item). How should I escape user's text to prevent interpreting it as RTF/HTML?
Solution
Use Qt::escape(const QString& plain)
function to escape HTML entities.
OTHER TIPS
Use QMessageBox::setTextFormat(Qt::PlainText)
to force it to interpret the text as plain text.
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow