You are saying that all insertions happen after the event loop has started. So the main window has already processed its show event.
Or are you creating a hidden window and calling show() when you have done all insertions?

Btw, it is very uncommon to handle placement and z-order of widgets manually. What do you want to achieve?

Cheers,
_