本页内容

QChildEvent Class

QChildEvent 类包含子对象事件的事件参数。更多内容...

头文件: #include <QChildEvent>
CMake: find_package(Qt6 REQUIRED COMPONENTS Core)
target_link_libraries(mytarget PRIVATE Qt6::Core)
qmake: QT += core
继承自: QEvent

公共函数

QChildEvent(QEvent::Type type, QObject *child)
bool added() const
QObject *child() const
bool polished() const
bool removed() const

受保护函数

QChildEvent(QChildEvent &&)
QChildEvent &operator=(QChildEvent &&)
QChildEvent &operator=(const QChildEvent &other)

详细说明

当子对象被添加或删除时,子事件会立即发送给对象。

在这两种情况下,您只能确保子对象是QObject (或者,如果QObject::isWidgetType()返回true ,则为QWidget )。这是因为在QEvent::ChildAdded 的情况下,子对象尚未完全构建;而在QEvent::ChildRemoved 的情况下,它可能已经被销毁了。

这些事件的处理程序是QObject::childEvent()。

成员函数文档

QChildEvent::QChildEvent(QEvent::Type type, QObject *child)

为child 构建一个特定type 的子事件对象。

type 参数可以是QEvent::ChildAdded 、QEvent::ChildRemoved 或QEvent::ChildPolished 。

另请参阅 child()。

[protected delete] QChildEvent::QChildEvent(QChildEvent &&)

通过移动构造一个QChildEvent 的实例。该函数已被删除。

bool QChildEvent::added() const

如果type()的值为QEvent::ChildAdded ,则返回true ;否则返回false。

QObject *QChildEvent::child() const

返回已添加或已删除的子对象。

bool QChildEvent::polished() const

如果 `type()` 的结果为 `QEvent::ChildPolished`,则返回 `true `;否则返回 `false`。

bool QChildEvent::removed() const

如果type()的结果是QEvent::ChildRemoved ,则返回true ;否则返回false。

[protected delete] QChildEvent &QChildEvent::operator=(QChildEvent &&)

将other 按移动赋值方式赋值给此QChildEvent 实例。该函数已被删除。

[noexcept protected default] QChildEvent &QChildEvent::operator=(const QChildEvent &other)

将other 复制并赋值给此QChildEvent 实例。

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