In addition to the previous answer:
1 Like it was mentioned if parent not null you widget will be rendered just inside parent widget.
2 If parent widget is deleted you all his child widgets will be also deleted by delete operator.
Correct implementation of default widget constructor should be the following:
class MyWidget: public QWidget {
Q_OBJECT
public:
explicit MyWidget(QWidget *parent = 0);
}
MyWidget::MyWidget(QWidget *parent = 0): QWidget(parent) {
// Your own initialization code
}
Try to avoid specifing nonzero parent for stack widget. You'd better always create nested widget in the way:
QWidget *parentWidget;
MyWidget myWidget = new MyWidget(parentWidget);
You can read more here:
http://doc.trolltech.com/4.6/objecttrees.html