You aren't doing the same thing as the original poster. He was trying to add the new QMainWindow as a direct child of the top-level QMainWindow. You are adding it as the main widget of a dock window.

In your case, you are following all of the QMainWindow "rules" even though the effect is different. It isn't really clear what the OP intended his GUI to look like. Maybe he wanted another main window that floats or docks like yours will.

I am guessing that what he wants is what Microsoft calls an "MDI" or "multiple document interface" app, where you can have several child windows within a main window frame. The menu, toolbars, and other main window components control whichever child window has focus.

But this is a 3-year-old post, so I am guessing that he either solved his problem or gave up.