QChildEvent Class

The QChildEvent class contains event parameters for child object events. More...

Header: #include <QChildEvent>
CMake: find_package(Qt6 REQUIRED COMPONENTS Core)
target_link_libraries(mytarget PRIVATE Qt6::Core)
qmake: QT += core
Inherits: QEvent

Public Functions

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

Protected Functions

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

Detailed Description

Child events are sent immediately to objects when children are added or removed.

In both cases you can only rely on the child being a QObject (or, if QObject::isWidgetType() returns true, a QWidget). This is because in the QEvent::ChildAdded case the child is not yet fully constructed; in the QEvent::ChildRemoved case it might have already been destructed.

The handler for these events is QObject::childEvent().

Member Function Documentation

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

Constructs a child event object of a particular type for the child.

type can be QEvent::ChildAdded, QEvent::ChildRemoved, or QEvent::ChildPolished.

See also child().

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

Move-constructs an instance of QChildEvent. This function is deleted.

bool QChildEvent::added() const

Returns true if type() is QEvent::ChildAdded; otherwise returns false.

QObject *QChildEvent::child() const

Returns the child object that was added or removed.

bool QChildEvent::polished() const

Returns true if type() is QEvent::ChildPolished; otherwise returns false.

bool QChildEvent::removed() const

Returns true if type() is QEvent::ChildRemoved; otherwise returns false.

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

Move-assigns other to this QChildEvent instance. This function is deleted.

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

Copy-assigns other to this QChildEvent instance.