本页内容

QQmlSA::PropertyPass Class

class QQmlSA::PropertyPass

所有针对属性的静态分析阶段的基类。更多...

头文件: #include <qqmlsa.h>
CMake: find_package(Qt6 REQUIRED COMPONENTS QmlCompiler)
target_link_libraries(mytarget PRIVATE Qt6::QmlCompiler)
继承自: QQmlSA::GenericPass
状态: 技术预览

该类处于技术预览阶段,可能会发生变更。

公共函数

PropertyPass(QQmlSA::PassManager *manager)
virtual void onBinding(const QQmlSA::Element &element, const QString &propertyName, const QQmlSA::Binding &binding, const QQmlSA::Element &bindingScope, const QQmlSA::Element &value)
virtual void onCall(const QQmlSA::Element &element, const QString &propertyName, const QQmlSA::Element &readScope, QQmlSA::SourceLocation location)
virtual void onRead(const QQmlSA::Element &element, const QString &propertyName, const QQmlSA::Element &readScope, QQmlSA::SourceLocation location)
virtual void onWrite(const QQmlSA::Element &element, const QString &propertyName, const QQmlSA::Element &expressionType, const QQmlSA::Element &writeScope, QQmlSA::SourceLocation location)

详细说明

成员函数文档

PropertyPass::PropertyPass(QQmlSA::PassManager *manager)

创建一个 PropertyPass 对象,并使用 `manager ` 来引用通行证管理器。

[virtual] void PropertyPass::onBinding(const QQmlSA::Element &element, const QString &propertyName, const QQmlSA::Binding &binding, const QQmlSA::Element &bindingScope, const QQmlSA::Element &value)

每当属性被绑定到某个值时执行。

element 的属性propertyName 通过binding 在bindingScope 中与value 建立了绑定。

[virtual] void PropertyPass::onCall(const QQmlSA::Element &element, const QString &propertyName, const QQmlSA::Element &readScope, QQmlSA::SourceLocation location)

每当调用属性或方法时都会执行。

element 的属性或方法propertyName 被readScope 中的一条指令作为函数调用,该指令定义在location 上。

注意:目前 仅支持对方法或属性的直接调用,间接调用(例如将方法存储到 JavaScript 变量中,然后调用该变量)不被识别。

[virtual] void PropertyPass::onRead(const QQmlSA::Element &element, const QString &propertyName, const QQmlSA::Element &readScope, QQmlSA::SourceLocation location)

每当读取属性时执行。

element 的propertyName 属性由readScope 中的一个指令读取,该指令定义在location 。

如果将属性propertyName 作为函数调用,也会执行此代码,因为这需要先读取该属性。

[virtual] void PropertyPass::onWrite(const QQmlSA::Element &element, const QString &propertyName, const QQmlSA::Element &expressionType, const QQmlSA::Element &writeScope, QQmlSA::SourceLocation location)

每当对某个属性进行写入操作时执行。

element 的属性propertyName 由writeScope 中的一条指令进行写入,该指令定义于location 。写入propertyName 的表达式的类型为expressionType 。

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