Reputation: 12249
when I make a new class in Qt based on QWidget, I get code that looks like this for the constructor,
Board::Board(QWidget *parent) : QWidget(parent) { }
It looks like the QWidget(parent) is part of an initialization list, but if that was true we'd be setting a variable called QWidget equal to the argument parent, correct? But I don't think there is any variable called QWidget. So is this a non-C++ concept and a concept specific to Qt to set the parent of a widget? Or is it actually a C++ concept? My best guess is that it's specific to Qt and you'd never see something like this in plain C++.
Upvotes: 1
Views: 660
Reputation: 8001
It's a C++ thing: the constructor of the base class is called.
For more details, see e.g.: Tech-FAQ: Constructors in Derived Class
Upvotes: 3