QQmlSA::SourceLocation Class
class QQmlSA::SourceLocation表示源代码中的某个位置或区域。更多...
| 标题: | #include <qqmlsasourcelocation.h> |
| CMake: | find_package(Qt6 REQUIRED COMPONENTS QmlCompiler) target_link_libraries(mytarget PRIVATE Qt6::QmlCompiler) |
| 状态: | 技术预览版 |
该类处于技术预览阶段,内容可能会有变动。
公共函数
| SourceLocation(quint32 offset = 0, quint32 length = 0, quint32 line = 0, quint32 column = 0) | |
| SourceLocation(const QQmlSA::SourceLocation &other) | |
| SourceLocation(QQmlSA::SourceLocation &&other) | |
| ~SourceLocation() | |
| quint32 | begin() const |
| quint32 | end() const |
| QQmlSA::SourceLocation | endZeroLengthLocation(QStringView text) const |
| bool | isValid() const |
| quint32 | length() const |
| quint32 | offset() const |
| quint32 | startColumn() const |
| quint32 | startLine() const |
| QQmlSA::SourceLocation | startZeroLengthLocation() const |
| QQmlSA::SourceLocation & | operator=(QQmlSA::SourceLocation &&other) |
| QQmlSA::SourceLocation & | operator=(const QQmlSA::SourceLocation &other) |
静态公共成员
(since 6.12) QQmlSA::SourceLocation | documentOrigin() |
相关的非成员
| qsizetype | qHash(const QQmlSA::SourceLocation &location, qsizetype seed = 0) |
| bool | operator!=(const QQmlSA::SourceLocation &lhs, const QQmlSA::SourceLocation &rhs) |
| bool | operator==(const QQmlSA::SourceLocation &lhs, const QQmlSA::SourceLocation &rhs) |
成员函数文档
[explicit] SourceLocation::SourceLocation(quint32 offset = 0, quint32 length = 0, quint32 line = 0, quint32 column = 0)
根据offset 、length 、line 和column 中给定的值,构建一个新的SourceLocation对象。
SourceLocation::SourceLocation(const QQmlSA::SourceLocation &other)
创建other 的副本。
[noexcept] SourceLocation::SourceLocation(QQmlSA::SourceLocation &&other)
从other 中移动并构造一个SourceLocation。
[noexcept] SourceLocation::~SourceLocation()
销毁此SourceLocation 实例。
quint32 SourceLocation::begin() const
返回此源位置起点的偏移量。
[static, since 6.12] QQmlSA::SourceLocation SourceLocation::documentOrigin()
返回任何 QML 文档原点的源位置。
该函数于 Qt 6.12 版本中引入。
quint32 SourceLocation::end() const
返回此源位置结尾处的偏移量。
QQmlSA::SourceLocation SourceLocation::endZeroLengthLocation(QStringView text) const
返回一个长度为零的源位置,该位置指向指向text 的源位置的末尾。
bool SourceLocation::isValid() const
返回true 表示SourceLocation 有效,否则返回false 。
quint32 SourceLocation::length() const
返回此源位置的长度。
quint32 SourceLocation::offset() const
返回此源位置起点的偏移量。
quint32 SourceLocation::startColumn() const
返回包含此源位置起始点的列号。
quint32 SourceLocation::startLine() const
返回包含此源代码位置起始处的行号。
QQmlSA::SourceLocation SourceLocation::startZeroLengthLocation() const
返回一个长度为零的源位置,该位置指向此源位置的开头。
[noexcept] QQmlSA::SourceLocation &SourceLocation::operator=(QQmlSA::SourceLocation &&other)
将other 赋值给此SourceLocation 。
QQmlSA::SourceLocation &SourceLocation::operator=(const QQmlSA::SourceLocation &other)
将other 分配给此SourceLocation 。
相关非会员
qsizetype qHash(const QQmlSA::SourceLocation &location, qsizetype seed = 0)
返回location 的哈希值,并使用seed 作为计算的种子。
bool operator!=(const QQmlSA::SourceLocation &lhs, const QQmlSA::SourceLocation &rhs)
如果lhs 不等于rhs ,则返回 true;否则返回false 。关于何时认为两个源位置相等,请参见SourceLocation::operator== 。
bool operator==(const QQmlSA::SourceLocation &lhs, const QQmlSA::SourceLocation &rhs)
如果 `lhs ` 与 `rhs` 相等,则返回 `true`;否则返回 `false `。如果两个 `SourceLocation` 的 `offset`、`length`、`line` 和 `column` 成员的值相同,则视为相等。
© 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.