Reputation: 48966
There is a statement in the foudations of Qt Development book that goes as follows:
MyClass::MyClass(const string& test, QObject *parent) : QObject( parent )
What is meant when we put : QObject( parent )
?
Thanks.
Upvotes: 1
Views: 5855
Reputation: 2960
When you create a QObject with another object as parent, it's added to the parent's children() list, and is deleted when the parent is.
Upvotes: 0
Reputation: 1980
In short this means that MyClass
inherits properties (and methods) from QObject
http://www.cplusplus.com/doc/tutorial/inheritance/
http://www.anyexample.com/programming/cplusplus/cplusplus_inheritance_example.xml
So MyClass
is a QObject
Upvotes: 0
Reputation: 95629
Are you sure that there aren't two constructor declarations? The : QObject(parent)
is an initializer list; it is initializing the base class QObject
with the QObject::QObject(QObject*)
constructor.
Upvotes: 3