just a part of a usual structured class in Qt:
class MyClass : public QWidget
{
Q_OBJECT
public:
MyClass(QWidget *parent = 0);
.
.
.
}
Looking at the constructor I don’t understand the meaning of the parameter (QWidget *parent = 0) ? What does this mean?
greetings
MyClass(QWidget *parent = 0)defines a constructor that can take aQWidget*.You might be confused at the
= 0part, which is C++ syntax for default arguments. Default arguments allow you to use the function without having to specify that particular argument. In the case of this, you could call this constructor like this:And this is equivalent to calling:
And that means that
MyClassobject will have no parentQWidget, because= 0means the parent is a null pointer.