6.0.0-rc4Source

QChildEvent Class

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

Header#include <QChildEvent>
CMaketarget_link_libraries(app PRIVATE Nt::Core)
ModuleNt Core C++ Classes
InheritsQEvent

List of all members, including inherited members

Public Functions

QChildEvent(Type type, QObject *child)
~QChildEvent()
QObject *child() const
booladded() const
boolpolished() const
boolremoved() const

Reimplemented Public Functions

QChildEvent *clone() const

Detailed Description

An object receives a ChildAdded event when it becomes the parent of another object, and a ChildRemoved event when a child is removed or destroyed. QObject::event() passes both to QObject::childEvent().

void Tracker::childEvent(QChildEvent *event) {
    if (event->added())
        qDebug() << "new child" << event->child();
}

See also QObject::childEvent() and QObject::setParent().

Differences from Qt

ChildPolished is defined, but Nt never sends it.

Member Function Documentation

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

Constructs a child event of the given type (ChildAdded, ChildPolished or ChildRemoved) for child.

[override] QChildEvent::~QChildEvent()

Destroys the child event.

bool QChildEvent::added() const

Returns true if the event is ChildAdded; otherwise returns false.

QObject * QChildEvent::child() const

Returns the child object that was added or removed.

[override] QChildEvent * QChildEvent::clone() const

Reimplements QEvent::clone().

bool QChildEvent::polished() const

Returns true if the event is ChildPolished; otherwise returns false.

bool QChildEvent::removed() const

Returns true if the event is ChildRemoved; otherwise returns false.