本页内容

QQmlSA::Element Class

class QQmlSA::Element

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

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

该类目前处于技术预览阶段,相关内容可能会有变动。

公共函数

Element()
Element(const QQmlSA::Element &other)
Element(QQmlSA::Element &&other)
~Element()
QQmlSA::AccessSemantics accessSemantics() const
QQmlSA::Element baseType() const
QString baseTypeName() const
QString defaultPropertyName() const
QString filePath() const
bool hasMethod(const QString &methodName) const
bool hasOwnProperty(const QString &propertyName) const
bool hasOwnPropertyBindings(const QString &propertyName) const
bool hasProperty(const QString &propertyName) const
bool hasPropertyBindings(const QString &name) const
QQmlSA::SourceLocation idSourceLocation() const
bool inherits(const QQmlSA::Element &element) const
bool isComposite() const
bool isFileRootComponent() const
bool isNull() const
bool isPropertyRequired(const QString &propertyName) const
QString name() const
QQmlSA::Method::Methods ownMethods() const
QQmlSA::Binding::Bindings ownPropertyBindings() const
QQmlSA::Binding::Bindings ownPropertyBindings(const QString &propertyName) const
QQmlSA::Element parentScope() const
QQmlSA::Property property(const QString &propertyName) const
QList<QQmlSA::Binding> propertyBindings(const QString &propertyName) const
QQmlSA::ScopeType scopeType() const
QQmlSA::SourceLocation sourceLocation() const
operator bool() const
bool operator!() const
QQmlSA::Element &operator=(QQmlSA::Element &&other)
QQmlSA::Element &operator=(const QQmlSA::Element &other)
size_t qHash(const QQmlSA::Element &key, size_t seed = 0)
bool operator!=(const QQmlSA::Element &lhs, const QQmlSA::Element &rhs)
bool operator==(const QQmlSA::Element &lhs, const QQmlSA::Element &rhs)

详细说明

成员函数文档

Element::Element()

创建一个新的 Element 对象。

Element::Element(const QQmlSA::Element &other)

创建other 的副本。

[noexcept] Element::Element(QQmlSA::Element &&other)

通过“Move”构造一个 Element 实例。

[noexcept] Element::~Element()

销毁该元素。

QQmlSA::AccessSemantics Element::accessSemantics() const

返回该元素的访问语义。例如:Reference、Value 或 Sequence。

QQmlSA::Element Element::baseType() const

返回该元素所继承的父元素。

QString Element::baseTypeName() const

返回该元素所继承的元素的名称。

QString Element::defaultPropertyName() const

返回此 Element 的默认属性名称。如果它没有默认属性,则返回一个空字符串。

QString Element::filePath() const

返回定义此元素的 QML 代码的文件路径。

bool Element::hasMethod(const QString &methodName) const

返回此元素是否具有名为methodName 的方法。

bool Element::hasOwnProperty(const QString &propertyName) const

返回此元素是否定义了一个名为propertyName 的属性,且该属性在其基类或扩展对象中未被定义。

bool Element::hasOwnPropertyBindings(const QString &propertyName) const

返回该元素是否具有未在其基对象或扩展对象中定义、且名称为propertyName 的属性绑定。

bool Element::hasProperty(const QString &propertyName) const

返回该元素是否具有名为propertyName 的属性。

bool Element::hasPropertyBindings(const QString &name) const

返回此元素是否具有名称为name 的属性绑定。

QQmlSA::SourceLocation Element::idSourceLocation() const

返回 QML 代码中为该元素(如果它有 id)分配 id 的位置。

bool Element::inherits(const QQmlSA::Element &element) const

返回该元素是否继承自element 。

bool Element::isComposite() const

对于通过 Qml 定义的对象,返回 `true `;对于通过 C++ 声明的对象,返回 `false `。

bool Element::isFileRootComponent() const

返回该元素是否为其 QML 文件的根组件。

bool Element::isNull() const

如果该元素为 null,则返回 `true `;否则返回 `false `。

bool Element::isPropertyRequired(const QString &propertyName) const

返回该元素上名称为propertyName 的属性是否为必填属性。如果找不到该属性,则返回 false。

QString Element::name() const

返回该元素的名称。

QQmlSA::Method::Methods Element::ownMethods() const

返回该 Elements 对象上未在其基类或扩展对象中定义的方法。

QQmlSA::Binding::Bindings Element::ownPropertyBindings() const

返回该元素的属性绑定,这些绑定在其基类或扩展对象上未被定义。

QQmlSA::Binding::Bindings Element::ownPropertyBindings(const QString &propertyName) const

返回该元素的属性绑定,这些绑定在其基对象或扩展对象上未定义,且名称为propertyName 。

QQmlSA::Element Element::parentScope() const

返回包含此元素的元素。

QQmlSA::Property Element::property(const QString &propertyName) const

如果在此元素或其基类和扩展对象中找到了名为propertyName 的属性,则返回该属性;否则返回一个无效属性。

QList<QQmlSA::Binding> Element::propertyBindings(const QString &propertyName) const

返回该元素中名称为propertyName 的属性绑定。

QQmlSA::ScopeType Element::scopeType() const

返回 Element 的作用域类型。

QQmlSA::SourceLocation Element::sourceLocation() const

返回 QML 代码中定义此元素的位置。

[explicit] Element::operator bool() const

如果该元素不为空,则返回true ;否则返回false 。

bool Element::operator!() const

如果该元素为 null,则返回 `true `;否则返回 `false `。

[noexcept] QQmlSA::Element &Element::operator=(QQmlSA::Element &&other)

将 `other ` 赋值给此 `Element` 实例。

QQmlSA::Element &Element::operator=(const QQmlSA::Element &other)

将other 分配给此元素实例。

相关非成员

[noexcept] size_t qHash(const QQmlSA::Element &key, size_t seed = 0)

返回key 的哈希值,并使用seed 作为计算的种子。

bool operator!=(const QQmlSA::Element &lhs, const QQmlSA::Element &rhs)

如果 `lhs ` 和 `rhs ` 不相等,则返回 `true `;否则返回 `false `。

bool operator==(const QQmlSA::Element &lhs, const QQmlSA::Element &rhs)

如果lhs 和rhs 相等,则返回 `true `;否则返回 `false `。

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