继承自QObject的对象可在构造函数中指定父对象,不指定则默认为空
父对象内存回收后,子对象的内存也一并回收
所有继承QObject的子类都应该有parent参数
class MyObject:public QObject
{
public:
MyObject(QObject *parent = 0);
~MyObject();
};
MyObject *parent = new MyObject();
MyObject *child = new MyObject(parent);
delete parent;