QChildEvent Class
QChildEvent 类包含子对象事件的事件参数。更多
头文件: | #include <QChildEvent> |
CMake: | find_package(Qt6 REQUIRED COMPONENTS Core) target_link_libraries(mytarget PRIVATE Qt6::Core) |
qmake: | QT += core |
继承: | QEvent |
- 所有成员(包括继承成员)的列表
- QChildEvent 属于事件类。
公共函数
QChildEvent(QEvent::Type type, QObject *child) | |
bool | added() const |
QObject * | child() const |
bool | polished() const |
bool | removed() const |
详细说明
当添加或删除子对象时,会立即向对象发送子对象事件。
在这两种情况下,您只能依赖于子对象是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().
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。
© 2025 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.