本页内容

Aggregation Namespace

“聚合”命名空间支持将相关组件打包,从而使每个组件都能向外部暴露其他组件的属性和行为。更多内容...

Header: #include <Aggregation>

类

class Aggregate

函数

void aggregate(const QObjectList &components)
T *query(QObject *obj)
QList<T *> query_all(QObject *obj)

详细说明

打包到聚合中的组件可以相互转换,并且具有耦合的生命周期。有关详细信息和示例,请参阅Aggregation::Aggregate 的文档。

类

类Aggregate

Aggregate 类定义了一组相关组件,这些组件可被视为一个整体。更多内容...

函数文档

void Aggregation::aggregate(const QObjectList &components)

这是一个便捷函数,用于创建一个新的聚合体,并将所有components 添加到其中。如果某些组件已经属于某个聚合体,则剩余的组件将添加到该聚合体中。这些组件最初不能属于不同的聚合体。

另请参阅 Aggregate 。

template <typename T> T *query(QObject *obj)

执行一次动态类型转换,该转换会考虑 `obj ` 可能所属的聚合类型。如果 `obj ` 本身就是请求的类型,则直接进行类型转换并返回。否则,如果 `obj ` 属于某个聚合类型,则会检查其所有组件;如果它不属于任何聚合类型,则返回 `null`。

另请参阅 Aggregate::component()。

template <typename T> QList<T *> query_all(QObject *obj)

如果obj 属于一个聚合类型,则返回所有可转换为该类型的所有组件。否则,如果它属于请求的类型,则返回obj 。

另请参阅 Aggregate::components()。

Copyright © The Qt Company Ltd. and other contributors. 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.