Qt Namespace
Qt 命名空间包含来自 QtGui 模块的以下元素。该命名空间的完整文档请参见 QtCore 模块 here.
函数
| QString | convertFromPlainText(const QString &plain, Qt::WhiteSpaceMode mode = WhiteSpacePre) |
| bool | mightBeRichText(QAnyStringView text) |
函数文档
QString Qt::convertFromPlainText(const QString &plain, Qt::WhiteSpaceMode mode = WhiteSpacePre)
将纯文本字符串plain 转换为 HTML 格式的段落,同时保留其大部分外观。
mode 定义了空格的处理方式。
该函数定义在<QTextDocument> 头文件中。
另请参阅 QString::toHtmlEscaped() 和mightBeRichText()。
bool Qt::mightBeRichText(QAnyStringView text)
如果字符串text 可能是富文本,则返回true ;否则返回false 。
该函数采用一种快速且简单的启发式算法。它主要检查第一个换行符之前是否存在类似标签的内容。虽然对于常见情况,结果可能是正确的,但无法保证其准确性。
该函数定义在<QTextDocument> 头文件中。
注意:在 Qt 6.7 之前的版本中,该函数仅接受QString 作为参数。
© 2026 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.