Qt's parent–child mechanism

Qt's parent–child mechanism is implemented in QObject. When we create an object (a widget,validator, or any other kind) with a parent, the parent adds the object to the list of its children.When the parent is deleted, it walks through its list of children and deletes each child. Thechildren themselves then delete all of their children, and so on recursively until none remain.The parent–child mechanism greatly simplifies memory management, reducing the risk ofmemory leaks. The only objects we must call delete on are the objects we create with new and that have no parent. And if we delete a child object before its parent, Qt will automatically remove that object from the parent's list of children.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值