I'm learning Qt, found this:
Widget::Widget(QWidget *parent)
: QWidget(parent), ui(new Ui::WidgetClass)
{
ui->setupUi(this);
}
what is ": QWidget(parent), ui(new Ui::WidgetClass)" mean?
And how can I get the C++ document about this?
I'm learning Qt, found this:
Widget::Widget(QWidget *parent)
: QWidget(parent), ui(new Ui::WidgetClass)
{
ui->setupUi(this);
}
what is ": QWidget(parent), ui(new Ui::WidgetClass)" mean?
And how can I get the C++ document about this?
This is nothing special with Qt, just part of C++.
: QWidget(parent)
is just calling the base contructor.
ui(new Ui::WidgetClass)
is just a member being initialized.
Example:
class B
{
public:
B(int x)
{
myx = x;
}
int myx;
};
class D : public B
{
public:
D()
: B(4), p(new char[1024])
{
}
~D()
{
delete[] p;
}
char *p;
};
The construct is called an initialization list and is used to initialize base classes and/or member variables in class constructors.
If you want to learn more about them (it's an essential concept in C++), see for example this document or ask 'the' google.
A reference for example:
http://www.cprogramming.com/tutorial/initialization-lists-c++.html
or just google "C++ initialization"