本页内容

QXmlLocator Class

QXmlLocator 类为 XML 处理类提供有关文件内解析位置的信息。更多内容...

头文件: #include <QXmlLocator>
CMake: find_package(Qt6 REQUIRED COMPONENTS Core5Compat)
target_link_libraries(mytarget PRIVATE Qt6::Core5Compat)
qmake: QT += core5compat

注意:该类中的所有函数均为可重入的。

公共函数

QXmlLocator()
virtual ~QXmlLocator()
virtual int columnNumber() const = 0
virtual int lineNumber() const = 0

详细说明

在开始解析文档之前,阅读器会通过QXmlContentHandler::setDocumentLocator()函数向内容处理程序报告一个QXmlLocator。此时,处理程序类可以使用该定位器来获取阅读器当前到达的位置(lineNumber()和columnNumber())。

成员函数文档

QXmlLocator::QXmlLocator()

构造函数。

[virtual noexcept] QXmlLocator::~QXmlLocator()

析构函数。

[pure virtual] int QXmlLocator::columnNumber() const

返回列号(从 1 开始计数);如果没有可用的列号,则返回 -1。

[pure virtual] int QXmlLocator::lineNumber() const

返回行号(从 1 开始计数);如果没有可用行号,则返回 -1。

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