In Line 5 you are creating a QWidget as a container, but you tell it that "MyWidget" is its parent ("this"). Then in Line 10, you create a QVBoxLayout with no parent and add the widget to that.

So what you are doing is telling MyWidget that "Here's a new child widget, but I won't tell you where to place it on screen. I've put it into a layout, but I won't tell you about that either. Oh, and I'm not going to call container->show() so it will just be a white square."

If you want the "childwindow" (whatever that is) to be visible independently of MyWidget, then don't make MyWidget the parent. If you want the container to be laid out properly in "childwindow", then you need to add the layout to it. And you need to call "show()" on the container so it becomes visible.