QXmlParseException Class
QXmlParseException 类用于报告与QXmlErrorHandler 接口相关的错误。更多内容...
| 标题: | #include <QXmlParseException> |
| CMake: | find_package(Qt6 REQUIRED COMPONENTS Core5Compat) target_link_libraries(mytarget PRIVATE Qt6::Core5Compat) |
| qmake: | QT += core5compat |
注意:该类中的所有函数均为可重入的。
公共函数
| QXmlParseException(const QString &name = QString(), int c = -1, int l = -1, const QString &p = QString(), const QString &s = QString()) | |
| QXmlParseException(const QXmlParseException &other) | |
| ~QXmlParseException() | |
| int | columnNumber() const |
| int | lineNumber() const |
| QString | message() const |
| QString | publicId() const |
| QString | systemId() const |
详细说明
当XML子系统检测到错误时,会构建该类的实例。您可以使用systemId()、publicId()、lineNumber()和columnNumber()方法,配合message()方法,获取错误发生的位置以及错误信息。可能的错误消息包括:
- “未发生错误”
- “由消费者触发的错误”
- “文件意外结束”
- “存在多个文档类型定义”
- “解析元素时发生错误”
- “标签不匹配”
- “解析内容时发生错误”
- “意外字符”
- “处理指令名称无效”
- “读取 XML 声明时预期有版本号”
- “独立声明的值不正确”
- “读取 XML 声明时预期出现编码声明或独立声明”
- “读取 XML 声明时预期出现独立声明”
- “解析文档类型定义时发生错误”
- “预期为字母”
- “解析注释时发生错误”
- “解析引用时发生错误”
- “DTD 中不允许使用内部通用实体引用”
- “属性值中不允许出现外部已解析的通用实体引用”
- “DTD 中不允许出现外部已解析的通用实体引用”
- “未解析的实体引用 n 处于错误上下文中”
- “递归实体”
- “外部实体的文本声明中存在错误”
请注意,如果您希望向应用程序的用户显示这些错误消息,除非已明确进行翻译,否则它们将以英文显示。
另请参阅 QXmlErrorHandler 和QXmlReader 。
成员函数文档
[explicit] QXmlParseException::QXmlParseException(const QString &name = QString(), int c = -1, int l = -1, const QString &p = QString(), const QString &s = QString())
针对列c ,公共标识符p 和系统标识符s ,生成一个解析异常,其错误字符串为name ,错误行号为l 。
QXmlParseException::QXmlParseException(const QXmlParseException &other)
创建other 的副本。
[noexcept] QXmlParseException::~QXmlParseException()
int QXmlParseException::columnNumber() const
返回发生错误的列号。
int QXmlParseException::lineNumber() const
返回发生错误的行号。
QString QXmlParseException::message() const
返回错误消息。
QString QXmlParseException::publicId() const
返回发生错误的公共标识符。
QString QXmlParseException::systemId() const
返回发生错误的系统标识符。
© 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.