I want to add childWidgets to a layouted parentWidget at runtime. I need to construct the children like

Qt Code:
  1. ChildWidget* child = new ChildWidget(parentWidget);
To copy to clipboard, switch view to plain text mode 

right? So now I would expect the child to be layed out according to the parentWidget's layout, but it doesn't happen. It seems like I explicitely have to:

Qt Code:
  1. ChildWidget* child = new ChildWidget(parentWidget);
  2. parentWidget->layout()->addWidget(child);
To copy to clipboard, switch view to plain text mode 

Is this the right way? It feels like I'm adding the child to the parent twice.