What is parent for in Qt?
Almost every QtWidgets class can have parent. And usually it's optional to set parent at object initialization. For example,If I create a class that inherits QWidget class, I will do the following on the constructor: Widget::Widget(QWidget* parent): QWidget(parent) { hbox = new QHBoxLayout(this); yes_button = new QPushButton("&Yes"); no_button = new QPushButton("&No", this); cancel_button = new QPushButton("&Cancel", hbox); } I can set or not set parent. I can set cancel_button to be a child of hbox . I can too set cancel_button to be a child of yes_button , but I think it's a bad thing to do.