@alogim
Hello,
Unfortunately, no. To make use of the parent-child mechanism your object must derive from QObject at least. Search through the forum for "QObject" and "RAII", Here is a thread where I've put some effort in explaining the QObject ownership. Back to your question:
class Object : public QObject
{
public:
Object(QWidget * parent = 0)
: QObject(parent)
{
}
};
Will do what you want, i.e. delete the Object when the parent is destroyed. Then you indeed create your object like this:
Object * obj = new Object(this);
and it's sufficient to ensure proper cleanup.
Kind regards.