QXmlParseException Class

QXmlParseException 类用于报告QXmlErrorHandler 接口的错误。更多

Header: #include <QXmlParseException>
CMake.QXmlParseException 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() 检索发生错误的位置。可能的错误信息有

  • "未发生错误
  • "用户触发的错误
  • "文件意外结束
  • "多于一个文件类型定义
  • "解析元素时发生错误
  • "标签不匹配
  • "解析内容时发生错误
  • "意外字符
  • "处理指令名称无效
  • "version expected while reading the XML declaration"
  • "独立声明值错误
  • "读取 XML 声明时预期编码声明或独立声明"。
  • "读取 XML 声明时预期出现独立声明" "读取 XML 声明时预期出现独立声明" "读取 XML 声明时预期出现独立声明
  • "解析文档类型定义时发生错误
  • "预计出现字母"
  • "解析注释时发生错误
  • "解析引用时发生错误
  • "DTD 中不允许内部一般实体引用
  • "属性值中不允许使用 "外部已解析一般实体引用
  • "DTD 中不允许外部已解析的一般实体引用
  • "未解析的实体引用 n 上下文错误
  • "递归实体
  • "外部实体文本声明中的错误

请注意,如果要向应用程序用户显示这些错误信息,除非明确翻译,否则将以英文显示。

另请参阅 QXmlErrorHandlerQXmlReader

成员函数文档

[explicit] QXmlParseException::QXmlParseException(const QString &name = QString(), int c = -1, int l = -1, const QString &p = QString(), const QString &s = QString())

构造一个解析异常,其错误字符串为name ,列c ,行l ,公共标识符p 和系统标识符s

QXmlParseException::QXmlParseException(const QXmlParseException &other)

创建other 的副本。

[noexcept] QXmlParseException::~QXmlParseException()

摧毁QXmlParseException.

int QXmlParseException::columnNumber() const

返回发生错误的列编号。

int QXmlParseException::lineNumber() const

返回发生错误的行号。

QString QXmlParseException::message() const

返回错误信息。

QString QXmlParseException::publicId() const

返回发生错误的公共标识符。

QString QXmlParseException::systemId() const

返回发生错误的系统标识符。

© 2025 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.