开发者

How to escape user-provided text as RTF in Qt4 before using it in eg. QMessageBox?

开发者 https://www.devze.com 2023-02-01 05:05 出处:网络
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 prev

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?


Use Qt::escape(const QString& plain) function to escape HTML entities.


Use QMessageBox::setTextFormat(Qt::PlainText) to force it to interpret the text as plain text.

0

精彩评论

暂无评论...
验证码 换一张
取 消