开发者

Default Initialization list in Qt Widget

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 w开发者_运维技巧as 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++.


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜