I have a Window with a Group Box
called Function control box
I want to include this window into that group box
I do that by using this code
ui->functionControlBoxGroupBox->setParent(componentIdentification);
Where componentIdentification
in an UI
object of the window above.
But it seems that nothing happens. Why?
This is what happening. From this:
To this:
Question:
How can I import a complete window form into a group box in QT?
CodePudding user response:
Conceptually, the group box is supposed to be the other window's parent (not the opposite), thus you should do:
componentIdentification->setParent(ui->functionControlBoxGroupBox);
A better way to do the same thing: set a layout to the parent (the group box) and add the child window to the layout, i.e., in construction:
ui->functionControlBoxGroupBox->setLayout(new QGridLayout());
somewhere else, later:
ui->functionControlBoxGroupBox->layout()->addWidget(componentIdentification);
This way, the group box is automatically set as the component's parent.