本页内容

QQmlSA Namespace

提供用于对 QML 程序进行静态分析的工具。更多内容...

标题: #include <qqmljsloggingutils.h>
CMake: find_package(Qt6 REQUIRED COMPONENTS QmlCompiler)
target_link_libraries(mytarget PRIVATE Qt6::QmlCompiler)
状态: 技术预览

此命名空间处于技术预览阶段,内容可能会发生变更。

类

(technology preview) class Binding
(technology preview) class DocumentEdit
(technology preview) class Element
(technology preview) class ElementPass
(technology preview) class FixSuggestion
(technology preview) class GenericPass
(technology preview) class LintPlugin
(technology preview) class LoggerWarningId
(technology preview) class Method
(technology preview) class PassManager
(technology preview) class Property
(technology preview) class PropertyPass
(technology preview) class SourceLocation

类型

(technology preview) enum class AccessSemantics { Reference, Value, None, Sequence }
(technology preview) enum class BindingType { Invalid, BoolLiteral, NumberLiteral, StringLiteral, RegExpLiteral, …, GroupProperty }
(technology preview) enum class MethodType { Signal, Slot, Method, StaticMethod }
enum class ScopeType { JSFunctionScope, JSLexicalScope, QMLScope, GroupedPropertyScope, AttachedPropertyScope, …, SignalHandlerFunctionScope }
(technology preview) enum class ScriptBindingKind { Invalid, PropertyBinding, SignalHandler, ChangeHandler }
(technology preview) enum class WarningSeverity { Error, Warning, Info, Disable }

详细说明

类

类Binding

表示针对特定类型的单个 QML 属性绑定。更多...

DocumentEdit类

表示对文档的单次编辑。更多...

类Element

表示一种 QML 类型。更多...

classElementPass

所有针对元素的静态分析处理的基类。更多...

类FixSuggestion

表示针对源代码中某个问题的修复建议。更多...

类GenericPass

静态分析处理的基类。更多...

类LintPlugin

所有静态分析插件的基类。更多...

classLoggerWarningId

QQmlSA 框架中用于唯一标识警告类别的字符串字面量封装类。更多...

classMethod

表示一个 QML 方法。更多...

classPassManager

可通过静态分析阶段对元素及其子元素进行分析。更多...

classProperty

表示一个 QML 属性。更多...

类PropertyPass

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

类SourceLocation

表示源代码中的某个位置或区域。更多...

类型文档

[technology preview] enum class QQmlSA::AccessSemantics

此枚举处于技术预览阶段,可能会发生变更。

描述了如何访问和共享一种类型。

常量值描述
QQmlSA::AccessSemantics::Reference0该类型的行为类似于Object 类型
QQmlSA::AccessSemantics::Value1该类型的行为与值类型类似
QQmlSA::AccessSemantics::None2该类型是一个命名空间,或者无效
QQmlSA::AccessSemantics::Sequence3该类型表现得像一个序列类型

另请参阅 《QML 类型系统》。

[technology preview] enum class QQmlSA::BindingType

此枚举处于技术预览阶段,内容可能会有变动。

描述QQmlSA::Binding 的类型。

常量值描述
QQmlSA::BindingType::Invalid0没有绑定
QQmlSA::BindingType::BoolLiteral1绑定是一个 bool 字面量
QQmlSA::BindingType::NumberLiteral2该绑定是一个数字字面量
QQmlSA::BindingType::StringLiteral3该绑定是一个字符串字面量
QQmlSA::BindingType::RegExpLiteral4该绑定是一个正则表达式字面量
QQmlSA::BindingType::Null5该绑定是一个空值字面量
QQmlSA::BindingType::Translation6该绑定是一个转换
QQmlSA::BindingType::TranslationById7该绑定是按 ID 进行的转换
QQmlSA::BindingType::Script8该绑定是一个正则脚本
QQmlSA::BindingType::Object9该绑定是一个对象
QQmlSA::BindingType::Interceptor10该绑定是一个拦截器,可以拦截对以下属性的写入操作:Behavior
QQmlSA::BindingType::ValueSource11该绑定是一个属性值源
QQmlSA::BindingType::AttachedProperty12该绑定是一个附加对象
QQmlSA::BindingType::GroupProperty13该绑定是一个分组属性

[technology preview] enum class QQmlSA::MethodType

此枚举处于技术预览阶段,可能会有变更。

描述QQmlSA::Method 的类型。

常量值描述
QQmlSA::MethodType::Signal0该方法是一个信号
QQmlSA::MethodType::Slot1该方法是一个槽
QQmlSA::MethodType::Method2该方法是Q_INVOKABLE 方法
QQmlSA::MethodType::StaticMethod3该方法是Q_INVOKABLE 的静态方法

enum class QQmlSA::ScopeType

描述 QML 作用域的类型。

常量值描述
QQmlSA::ScopeType::JSFunctionScope0该作用域是一个 JavaScript 函数:
Item {
    function f() : int { <- begin
        return 1
    } <- end
}
QQmlSA::ScopeType::JSLexicalScope1作用域是一个 JavaScript 词法作用域:
property int i: { <- begin
    let a = 1
    { <- begin
        console.log("hello")
    } <- end
    return a
} <- end
QQmlSA::ScopeType::QMLScope2该作用域是一个 QML 对象:
Item { <- begin
    x: 50
} <- end
QQmlSA::ScopeType::GroupedPropertyScope3该作用域是一个分组属性:
Text {
    font { <- begin
        pixelSize: 12
        bold: true
    } <- end
}
QQmlSA::ScopeType::AttachedPropertyScope4作用域是一个附加属性:
Item {
    Component.onCompleted: console.log("Hello")
    ^^^^^^^^^
             \ Scope of attached property Component
}
QQmlSA::ScopeType::EnumScope5该作用域是一个 QML枚举:
enum E { <- begin
    A,
    B,
    C
} <- end
QQmlSA::ScopeType::BindingFunctionScope (since Qt 6.11)6作用域表示绑定中的表达式:
Item {
    width: <- begin 10 +
        2 *parent.width <- end
}

在 Qt 6.11 之前,这被报告为 JSFunctionScope

常量值描述
QQmlSA::ScopeType::SignalHandlerFunctionScope (since Qt 6.11)7该作用域表示用作信号处理程序的函数:
Timer {
    onTriggered: <- begin console.log("hi") <- end
}

在 Qt 6.11 之前,这被报告为 JSFunctionScope

每个条目均附有 QML 代码中对应类型的示例作用域。

[technology preview] enum class QQmlSA::ScriptBindingKind

此枚举处于技术预览阶段,可能会有变动。

描述了类型为Script 的QQmlSA::Binding 的脚本类型。

常量值描述
QQmlSA::ScriptBindingKind::Invalid0绑定具有无效的脚本
QQmlSA::ScriptBindingKind::PropertyBinding1该绑定绑定到一个属性
QQmlSA::ScriptBindingKind::SignalHandler2该绑定是一个信号处理程序
QQmlSA::ScriptBindingKind::ChangeHandler3该绑定是一个变化处理程序

[technology preview] enum class QQmlSA::WarningSeverity

此枚举目前处于技术预览阶段,内容可能会有变动。

用于存储某个日志类别中诊断消息可能的严重性级别。

常量值描述
QQmlSA::WarningSeverity::ErrorQtMsgType::QtCriticalMsg此日志类别发出的消息将引发错误。
QQmlSA::WarningSeverity::WarningQtMsgType::QtWarningMsg此日志类别发出的消息为警告。除非设置了MaxWarnings且超过该值,否则不会产生错误。
QQmlSA::WarningSeverity::InfoQtMsgType::QtInfoMsg此日志类别发出的消息仅供参考,不计入MaxWarnings。
QQmlSA::WarningSeverity::Disable100此日志类别不会发出任何消息。

该枚举类型自 Qt 6.12 起引入。

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